colon keywords

66 views
Skip to first unread message

Neil Van Dyke

unread,
Oct 14, 2015, 1:12:39 AM10/14/15
to Racket-Dev List
I think that Racket 6.3 would be a great time to make `:abc` read the
same as `#:abc`.

For those of us who are pained deeply by `#:abc`, being able to use
`:abc` would be a big aesthetic improvement for Racket.

Neil V.

Alexis King

unread,
Oct 14, 2015, 1:32:52 AM10/14/15
to Neil Van Dyke, Racket-Dev List
> I think that Racket 6.3 would be a great time to make `:abc` read the same as `#:abc`.

This sounds like an incredibly breaking change. I support it in general, I think, but it seems like another feature that makes sense for Racket 2/Remix/whatever it ends up being called. I’m sure there are plenty of existing programs that use leading colons in symbols/identifiers.

Perhaps you could do an audit on all the packages and see how much breakage occurs with this change? That wouldn’t be definitive, of course, but it would be a good start.

What prompts you to suggest this for Racket 6.3 as opposed to any other version? Or is it arbitrary? (Also, there’s no way this would make it into 6.3 given that the release has already begun, even if it weren’t so huge.)

I guess it just seems like a potentially highly-destructive change for relatively little gain. The extra character certainly doesn’t feel like enough to make me “pained deeply”. A more interesting and less breaking change might be to make keywords self-quoting... but that’s a separate point entirely.

Neil Van Dyke

unread,
Oct 14, 2015, 1:45:47 AM10/14/15
to Alexis King, Racket-Dev List
Alexis King wrote on 10/14/2015 01:32 AM:
>> I think that Racket 6.3 would be a great time to make `:abc` read the same as `#:abc`.
> This sounds like an incredibly breaking change.

It should not be a breaking change.

Anyone who has used a colon as a leading character in a symbol (other
than the one-character symbol `:`) in a Lisp-family language, for
anything other than the same purpose as a Racket keyword, deserves what
they get.

> What prompts you to suggest this for Racket 6.3 as opposed to any other version?

I make this request periodically.

> I guess it just seems like a potentially highly-destructive change for relatively little gain.

I think it's not destructive, nor even disruptive. And it's for a big
gain, for some people.

> The extra character certainly doesn’t feel like enough to make me “pained deeply”.

Some people are high-verbal, some are high-visual, some are both.
Different people have different aesthetic senses. Racket should be a
beautiful friend to all people.

Neil V.

Laurent

unread,
Oct 14, 2015, 4:50:38 AM10/14/15
to Neil Van Dyke, Alexis King, Racket-Dev List
Or why not write a reader adapter to racket/base (à la Scribble's at-exp-reader) that does precisely that? Then you could use it if you like without breaking anything I suppose and meet your request of a beautiful-for-all Racket.



--
You received this message because you are subscribed to the Google Groups "Racket Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to racket-dev+...@googlegroups.com.
To post to this group, send email to racke...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/racket-dev/561DEC09.6040304%40neilvandyke.org.

For more options, visit https://groups.google.com/d/optout.

Jens Axel Søgaard

unread,
Oct 14, 2015, 5:34:01 AM10/14/15
to Neil Van Dyke, Alexis King, Racket-Dev List
2015-10-14 7:45 GMT+02:00 Neil Van Dyke <ne...@neilvandyke.org>:
Alexis King wrote on 10/14/2015 01:32 AM:
I think that Racket 6.3 would be a great time to make `:abc` read the same as `#:abc`.
This sounds like an incredibly breaking change.

It should not be a breaking change.

As far as I know this is standard practice:
    (require (prefix-in : parser-tools/lex-sre)
/Jens Axel


 

Robby Findler

unread,
Oct 14, 2015, 7:40:52 AM10/14/15
to Neil Van Dyke, Racket-Dev List
It would not be too hard, I believe, to add a parameter to the reader
so that symbols starting with colons read the same as keywords, and
then to build a language like s-exp and at-exp that would let you use
that notation in a fairly seamless and interop-friendly way. Even
getting syntax coloring shouldn't be too hard.


Robby
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-dev+...@googlegroups.com.
> To post to this group, send email to racke...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-dev/561DE446.4070905%40neilvandyke.org.

Jay McCarthy

unread,
Oct 14, 2015, 7:42:03 AM10/14/15
to Neil Van Dyke, Alexis King, Racket-Dev List
Can people fill out this form with their feelings?

http://goo.gl/forms/Kwl3uZVMsb
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-dev+...@googlegroups.com.
> To post to this group, send email to racke...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-dev/561DEC09.6040304%40neilvandyke.org.
>
> For more options, visit https://groups.google.com/d/optout.



--
Jay McCarthy
Associate Professor
PLT @ CS @ UMass Lowell
http://jeapostrophe.github.io

"Wherefore, be not weary in well-doing,
for ye are laying the foundation of a great work.
And out of small things proceedeth that which is great."
- D&C 64:33

Jay McCarthy

unread,
Oct 14, 2015, 7:51:49 AM10/14/15
to Robby Findler, Neil Van Dyke, Racket-Dev List
It is simpler than a reader parameter:

#lang racket/base

(define read-colon-keyword
(case-lambda
[(ch port)
(string->keyword (symbol->string (read/recursive port)))]
[(ch port src line col pos)
(datum->syntax #f (read-colon-keyword ch port)
(list src line col pos))]))

(define (make-colon-keyword-readtable)
(make-readtable (current-readtable)
#\:
'non-terminating-macro
read-colon-keyword))

(module+ test
(require rackunit)
(define (reads in out)
(check-equal? (read (open-input-string in)) out))
(parameterize ([current-readtable (make-colon-keyword-readtable)])
(reads "a:b" 'a:b)
(reads ":a" '#:a)
(reads "#:a" '#:a)))
> To view this discussion on the web visit https://groups.google.com/d/msgid/racket-dev/CAL3TdONVr2%3DVr86PE6Tbjj_hQP%3DCpcdkdoKbLyP%3DLgpfVjjvmw%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.



Alex Knauth

unread,
Oct 14, 2015, 8:31:21 AM10/14/15
to Jay McCarthy, Robby Findler, Neil Van Dyke, Racket-Dev List
Should we make this into a meta-language?

#lang colon-kw racket
(define (a:b a :b c) (+ a c))
(a:b -1 :b -5)

That way it would not be a change to racket and it wouldn't break everything, but those who want it can have it.
> To view this discussion on the web visit https://groups.google.com/d/msgid/racket-dev/CAJYbDanh%3DQ%2BEqYeXA%2Be%2BabSndPYTMupCSLr09WV6u5w1aWkkDg%40mail.gmail.com.

Robby Findler

unread,
Oct 14, 2015, 8:32:56 AM10/14/15
to Alex Knauth, Jay McCarthy, Neil Van Dyke, Racket-Dev List
That's what I meant to be saying. And yes: stupid me to forget about readtables!

Robby

Alex Knauth

unread,
Oct 14, 2015, 10:54:56 AM10/14/15
to Robby Findler, Jay McCarthy, Neil Van Dyke, Racket-Dev List
I just implemented that here:

Although it will give you a read error for things like :123 or other things where the part after the colon isn't a symbol. 

Neil Van Dyke

unread,
Oct 14, 2015, 11:10:05 AM10/14/15
to Racket-Dev List
I should have added: I've secretly already have a kludge that does this
(unreleased `#lang paddle`). But I don't want to use the kludge because
it effectively fragments the Racket language for no good reason. There
is, however, really good reason to add colon-keywords to `#lang
racket/base` and `#lang racket`.

Neil V.

Neil Van Dyke

unread,
Oct 14, 2015, 11:24:02 AM10/14/15
to Jay McCarthy, Racket-Dev List
Jay McCarthy wrote on 10/14/2015 07:42 AM:
> Can people fill out this form with their feelings?
>
> http://goo.gl/forms/Kwl3uZVMsb

Should a survey be posted to "racket-users"? (I posted to "racket-dev"
because I didn't want to incite an angry mob of colon-keyword's legion
supporters. But aesthetic preferences are things language users have.)

If "racket-users", then I think the ambiguous survey question "Is it
worth changing?" could use rephrasing or explanation. ("Should the
standard Racket #langs support `:keyword` in addition to `#:keyword`?")

Neil V.

Jay McCarthy

unread,
Oct 14, 2015, 11:25:44 AM10/14/15
to Neil Van Dyke, Racket-Dev List
I added you to the form, and please post away to users or wherever.
Canvas for your side!

Vincent St-Amour

unread,
Oct 14, 2015, 11:51:53 AM10/14/15
to Neil Van Dyke, Racket-Dev List
That's the beauty of doing it as a language "mixin", like `s-exp` or
`at-exp`. It composes with #langs, and does not really risk fragmentation.

Vincent
> --
> You received this message because you are subscribed to the Google Groups "Racket Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to racket-dev+...@googlegroups.com.
> To post to this group, send email to racke...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/racket-dev/561E704B.7020903%40neilvandyke.org.

John Griffin

unread,
Oct 14, 2015, 3:38:46 PM10/14/15
to Racket Developers
I would definitely prefer : over #: ... however, I dislike sanctioning of multiple things for the same purpose.   For instance, two small annoyances for me are 

1) that square braces [] seem to be the same as parentheses in Racket.  Thus, I cannot without a non-standard reader use their succinct nature for something else useful.   To me, (let ((this that)) is just as fine as (let ([this that]); in fact, I waste more time thinking about whether it's (parameterized [(this that)] or ([this that]).  

2) that commas are just whitespace in Clojure, thus leading to not being able to assign a more established Lisp meaning to the comma.

There is public relations breakage potential beyond tokenization.  After DrRacket would be adjusted to accommodate new token meaning to :colon-entities, other displayers such as emacs and syntax coloring utilities on the web would be a long off before they accommodated the Racket community's needs, reducing Racket's aesthetics, not improving it.  Maintainers of those utilities probably have Racket lower on their list than we do.

For my uses of Racket, it is more important that the main developers continuing to spend their time on performance enhancements and marketing instead of expending energy dealing with the inevitable blowback from people who chose legally and perhaps with purpose to use colons.

I agree with the aesthetic, but not the cost-benefit.
Reply all
Reply to author
Forward
0 new messages