[racket-dev] Keywords

From: Neil Van Dyke (neil at neilvandyke.org)
Date: Mon Jun 17 11:28:42 EDT 2013

Laurent wrote at 06/07/2013 02:12 AM:
>
> What I'd really like, for the sake of flexibility / ease of use, is to
> have no explicit keyword argument, but all arguments are implicit 
> ones, so
> that you can call a function by mixing by position and by name as you 
> like,
> without having specified so in the function's header.
> (Visual Basic[1] and Python[2] do something along these lines.)
>

I have used this in Python, and it is kinda neat and has its uses, but 
overall, I prefer the current way in Racket.

One reason I prefer the current way in Racket is that, if every argument 
can be positional, then you have to keep this in mind when adding 
keyword arguments to a procedure that is used by other code: new 
arguments can only be added at the end of the list, even if that does 
not make the most sense for documentation purposes.

Another reason is that the keyword arguments restrict the syntax 
somewhat, so, when a mistaken extraneous sexp is where we'd expect a 
keyword, it is flagged as an error, rather than be considered a 
positional argument.

Related to the previous reason, if the programmer is *intentionally* 
intermixing keyword arguments with positionals, such as "(foo 37 #:x 41 
74 #:a 34)", that seems error-like that I wish they would get an error 
and change their ways.

Neil V.


Posted on the dev mailing list.