Clearer code in DrRacket?

90 views
Skip to first unread message

Adam El Mazouari

unread,
Oct 9, 2020, 8:16:11 AM10/9/20
to Racket Users
Hello everyone.

I've started using DrRacket a couple of weeks ago and I can't get used to the color theme. Variables, identifiers, methods, all of them are in blue. It's really unintuitive. Does anybody know a good plugin that differentiates these in a clear way for the human eye?

Or, if you know something better than DrRacket in that regard, feel free to write down.

Thanks in advance!

Adam

Sam Tobin-Hochstadt

unread,
Oct 9, 2020, 9:35:26 AM10/9/20
to Adam El Mazouari, Racket Users
Can you give an example of which things you'd like to be different? We
usually use "variable" and "identifier" for very similar meanings when
discussing Racket, for example.

Sam
> --
> You received this message because you are subscribed to the Google Groups "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to racket-users...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/0ddf205e-c461-40d3-857b-4b5f75e60284n%40googlegroups.com.

Adam El Mazouari

unread,
Oct 9, 2020, 10:12:13 AM10/9/20
to Sam Tobin-Hochstadt, racket...@googlegroups.com
An example is this:

(define (square-all lst) (if (null? lst)

'()
(
cons (square (car lst))

(square-all (cdr lst)))))


As you can see, you've got:
  • methods included by default (define, cons)
  • booleans (null?)
  • user-introduced vars (lst)
shown in the same color. It's really not clear. I'd like for them to be in different colors.

--Adam.

Adam El Mazouari

unread,
Oct 9, 2020, 10:26:30 AM10/9/20
to Jason Hemann, racket...@googlegroups.com
... and what is this thing exactly?

--Adam.


On Fri, Oct 9, 2020 at 4:15 PM Jason Hemann <jason....@gmail.com> wrote:
https://racket-mode.com/

....

¯\_(ツ)_/¯

JBH

Sam Tobin-Hochstadt

unread,
Oct 9, 2020, 11:03:59 AM10/9/20
to Adam El Mazouari, racket...@googlegroups.com
If you'd like to see different colors for imported identifiers, then
you can click the "Check Syntax" button in DrRacket. The attached
picture shows what it looks like.

Note that there's not a difference between `cons` and `null?` because
those are both functions.

You can adjust the particular colors chosen in the Preferences dialog,
under the Check Syntax tab.

Sam


On Fri, Oct 9, 2020 at 10:12 AM Adam El Mazouari
<adam.el...@gmail.com> wrote:
>
> An example is this:
>
> (define (square-all lst) (if (null? lst)
>
> '()
> (cons (square (car lst))
>
> (square-all (cdr lst)))))
>
>
> As you can see, you've got:
>
> methods included by default (define, cons)
> booleans (null?)
> user-introduced vars (lst)
>
> shown in the same color. It's really not clear. I'd like for them to be in different colors.
>
> --Adam.
>
> On Fri, Oct 9, 2020 at 3:35 PM Sam Tobin-Hochstadt <sa...@cs.indiana.edu> wrote:
>>
Screenshot from 2020-10-09 11-01-19.png

George Neuner

unread,
Oct 9, 2020, 11:06:35 AM10/9/20
to Adam El Mazouari, racket...@googlegroups.com

On 10/9/2020 10:11 AM, Adam El Mazouari wrote:
An example is this:

(define (square-all lst) (if (null? lst)

'()
(
cons (square (car lst))

(square-all (cdr lst)))))


As you can see, you've got:
  • methods included by default (define, cons)
  • booleans (null?)
  • user-introduced vars (lst)
shown in the same color. It's really not clear. I'd like for them to be in different colors.

--Adam.

The colors of most things in DrRacket are adjustable: see Preferences in the Edit menu.  There are several general color schemes and/or you can set colors individually for most syntax items.

Note that there are multiple (2nd level) tabs under Color [and also under Editing].

George






















Shu-Hung You

unread,
Oct 9, 2020, 1:48:42 PM10/9/20
to Adam El Mazouari, Racket Users
Here is an example that provides different colors for some particular
forms such as define, require, lambda etc. However, these forms
('keywords') are recognized literally by the lexer instead of
semantically as in Check Syntax. Therefore it will classify
non-keywords as keywords from time to time.
https://github.com/shhyou/drracket-scheme-dark-green

More color schemes can be found here:
https://pkgd.racket-lang.org/pkgn/search?tags=colorscheme

On Fri, Oct 9, 2020 at 9:12 AM Adam El Mazouari
> To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/CAEGV_UybZ_m15Np%2BrJ51JWPhVkMhahESp9pRUet1%3DOTG5YOddQ%40mail.gmail.com.

Adam El Mazouari

unread,
Oct 10, 2020, 9:59:34 AM10/10/20
to shh...@u.northwestern.edu, racket...@googlegroups.com
Looks interesting. Do you know any package of this type for DrRacket (or another program) that works semantically while you program? (not just as a checking tool like View Syntax)

--Adam.

Sorawee Porncharoenwase

unread,
Oct 10, 2020, 1:45:47 PM10/10/20
to Adam El Mazouari, shh...@u.northwestern.edu, Racket list
Looks interesting. Do you know any package of this type for DrRacket (or another program) that works semantically while you program? (not just as a checking tool like View Syntax)

I think it would be difficult. 

Racket has macros, and it allows shadowing on anything. The attached image shows how `(if 1 2 3)` is colored differently by Check Syntax due to the interaction with macros and shadowing.

Screen Shot 2020-10-10 at 10.07.00.png

To identify which context `(if 1 2 3)` is in, you need to macro-expand the program and then analyze the expanded program (this is exactly what the Check Syntax button does). However, macro expansion could be very expensive. Syntax highlighting on the other hand is supposed to be very cheap and done immediately as you edit the program. I believe this is why DrRacket doesn't support syntax highlighting that you described.

If you are OK with a delay (you type something and it's colored, say, 10 seconds later), I think it's possible to use the result from the online Check Syntax, which macro-expands your program continuously in the background, to color the program.
Reply all
Reply to author
Forward
0 new messages