renatoathaydes / ansi-color

A Racket library to make it easy to colorize terminal output
Other
5 stars 0 forks source link

Documentation on racket-lang has bugs #1

Open 3geek14 opened 4 years ago

3geek14 commented 4 years ago

Here's the documentation on racket-lang.

Firstly, the documentation claims there's a make-pb&j function that doesn't exist. Jokes are fine, but I don't like misinformation. Clearly, the way to fix this is to implement that as a function which prints a colored ASCII-art sandwich to the console, and various types of jelly are simply aliases for colors. I'm willing to assist with this, but I'm not the best artist.

Second, the quick reference for with-colors is incorrect in usage. It'd be nice if that usage worked, but the displayln needs to be wrapped in a lambda.

renatoathaydes commented 4 years ago

Hey @3geek14 ! Sorry about that joke :) it was actually unintentional!! I was using the docs guide to learn how to generate Racket docs and must've forgotten the example in my docs....

But feel free to submit a PR with a real implementation that uses colors and ASCII art!

I will fix the wrong docs and make the with-colors function accept also quoted lists, so you can do (with-colors 'red 'white '(displayln "hello")).

3geek14 commented 4 years ago

Ooh, if you're going to change it to accept a list, you could put it into a begin and accept multiple commands, such as

(with-colors 'red 'white '(display "Hello, " displayln "world!"))

I'm working on the artwork.

renatoathaydes commented 4 years ago

Hi @3geek14 I've been playing with the idea of evaluating the quoted list to allow calls like the one you posted above, but it's harder than I thought initially.

As far as I can see, the quoted list is evaluated in the namespace of my module, not of the calling module. That means that if you use something from your own namespace, it will blow up:

(define x "hello")
(with-colors 'red 'white '(displayln x))

Error:

x: undefined;
 cannot reference an identifier before its definition

So, very inconvenient! I tried playing with namespaces but there seems to be no way to call eval with the caller's namespace, unless the caller gives us theirs! But then, this is no longer convenient, so unless there's a way to do this that I cannot see myself, I am going to have to drop the idea and stick with lambdas.