I don't really have a horse in this race. My position is very similar to Alexis 
which is why I didn't vote in the poll too. When I first arrived to Racket the 
#: syntax made me go "what in the world?" Since then I've grown to appreciate 
the reasoning behind the deliberate eye catching keyword syntax. 

I appreciate that Racket takes a principled approach to making language 
concepts precise and avoid muddling together distinct purposes as many other 
languages do. Racket keywords are just that, syntactic tags denoting function 
application arguments no more no less. I think for people coming from other  
languages with :keywords, Racket's #:keywords help to signal that they are not 
anything like how :keywords are usually used.

Honestly I think that an alternative keyword syntax should not be in the base 
language, the ship has already long since sailed and it would be a mistake to 
try to reverse course and fix it for sake of aesthetics. Racket already uses # 
to suggest syntax specialness, like #t, #f, #', #(), #<>, #lang. To me, #: 
seems to naturally fit into that category.

It would be far better to put the alternative in a meta-language that people 
can choose to use or not. Concerns about snippets containing :keywords posted 
to social media and elsewhere leading to confusion also apply equally to 
snippets of other non-base languages. I've seen several cases of scribble and 
other snippets being posted without #lang supplied and if I tried blindly 
running them directly in Racket, I'd get errors. If anything this should remind 
us that providing #lang is mandatory, not optional and adjust our habits to be 
more careful in the future when posting to social media.

Now that's been said, I'm with gneuner2. I'd love to see existential/toggle 
keywords.

If I may tweak his proposal a bit, something like 

(define (foo #:keyword (id)) (if (id) 'foo 'bar))

Basically if an identifier just by itself is given in the list immediately 
following the keyword, then it's treated as boolean. When keyword is supplied 
in a function call, then id evaluates to #t otherwise it's #f. If someone 
provides a value with the keyword - which does not presents an issue - id will 
be bound to that value which will still be treated as truthy, unless the value 
happens to be #f.

So based off the grammar from Racket Reference for define 
http://docs.racket-lang.org/reference/define.html

We'd be adding another clause to the arg production rule.

arg             =               arg-id
                |               [arg-id default-expr]
                |               keyword arg-id
                |               keyword [arg-id]
                |               keyword [arg-id default-expr]


Aλexander



On Saturday, November 21, 2015 at 6:06:58 PM UTC-5, gneuner2 wrote:
> Coming late to this.
> 
> On Wed, 14 Oct 2015 11:50:41 -0400, Neil Van Dyke
> <n...@neilvandyke.org> wrote:
> 
> >We are conducting a highly scientific poll.
> >
> >The question we want to answer is whether people would like for the 
> >Racket standard languages to have symbols that begin with the colon 
> >character (except for the symbol `:`) to read the same has keywords that 
> >begin with pound-colon.
> 
> I actually prefer the #: syntax, but what I would like is support for
> "existence" keywords - i.e. keywords with no argument - where the only
> thing you care about is whether or not the keyword was provided.
> 
> Obviously, this can be done using a "rest" argument and symbols, but
> the #: syntax draws attention that other symbols do not because
> DrRacket, at least by default, colors keywords differently from other
> symbols.
> 
> Although the keyword syntax coloring still works with a tick before a
> symbol that looks like a keyword, having to remember the tick is a
> PITA when you are thinking of the symbol as a keyword.  If you forget
> it, you get a  nasty
>     "application: missing argument expression after keyword"
> error.
> 
> 
> How much trouble would it cause to allow naked keywords and provide a
> predicate based on their name?  E.g.,
> 
> (define ( test blah #:opt #:req req )
>    :
>   (when #:opt?  ... )
>    :
>   )
> 
> (test #:req 3)
> (test #:req 42 #:opt)
> 
> Or even something like  (define ( test blah #:opt [] #:req req ) which
> makes it more obvious that the keyword is only there to be tested?
> 
> George

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to