[Python-ideas] relaxing keyword usage restrictions
Stephen J. Turnbull
stephen at xemacs.org
Sat Sep 10 05:09:16 CEST 2011
H Krishnan writes:
> In my 10+ years in scheme, I have never used 'define' as a symbol,
Of course you have used 'define' as a symbol. The rules of expression
evaluation in Scheme say "evaluate the first element of a list, and
apply the result to the rest of the list as arguments." When 'define'
is the first element of a list, it is evaluated as a symbol, ie, the
content of the value cell of the symbol 'define' is retrieved.
Conventionally, that cell contains a function that sets the value
of the second argument to the value of the third argument.
You can't really get away with saying, "I haven't used it as a
variable", either, since taking the value of a symbol is using it as a
So the design of Scheme (and Lisps in general) is very elegant,
because everything is determined by the arrangement of parentheses.
There is no need for reserving keywords. However, not all languages
are Lisps. Vive la difference!
Except that as somebody pointed out, there is a need. It turns out
that users want keywords in the form of "constants that evaluate to
themselves". So in the end you're at the same place, just a different
balance. (I know that Scheme does not have them, although they can be
created using define -- that's Schemingly correct, of course. But
other languages have made a deliberate choice to introduce them, cf.
> If syntax highlighting tools can use python's ast and other modules
> to identify keywords (instead of using their own parsers), the
> domino effect will be lesser.
They can't. Think editors written in Lisp.
 With apologies to the Francophones present for my spelling.
More information about the Python-ideas