[racket-dev] Keywords

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Thu Jun 6 19:42:58 EDT 2013

At Thu, 9 May 2013 16:22:54 +0200, Laurent wrote:
> On Mon, May 6, 2013 at 2:52 PM, Matthew Flatt <mflatt at cs.utah.edu> wrote:
> 
> > Anything is open for discussion, but speaking for myself, I'm not
> > interested in revisiting keyword syntax or case sensitivity.
> >
> 
> I've always wondered why the syntax of keywords implied two elements: the
> #:keyword and the identifier.
> I find that quite heavy for procedure headers, and most of the time I use
> the same symbol for the identifier and the keyword (and when I don't it's
> because I'm simply lazy and use a shorter identifier).
> 
> Is there a rationale somewhere for that?

The rationale is to make function definitions have the same shape as
function calls.

For example, in

 (define (f x) ....)

the `(f x)' imitates the shape of a call, which has formal-argument
variables replaced with actual-argument expressions:

 (f 5)

Similarly, in

 (define (f x #:mode m) ....)

the `(f x #:mode m)' reflects the shape of a call

 (f 5 #:mode 'fast)


> Would it be a bad idea for Racket2 to consider that keyword identifiers are
> the same as the keyword without the `#:' ?

I agree that it sometimes feels redundant to write both a keyword and
an identifier in a function's formal arguments, since they're often
spelled the same way. I can only say that I've tried things that way,
and I prefer the current way (so, I think I'd vote to keep it as-is).


Posted on the dev mailing list.