[Python-ideas] relaxing keyword usage restrictions
hetchkay at gmail.com
Sat Sep 10 05:20:12 CEST 2011
On Sat, Sep 10, 2011 at 8:39 AM, Stephen J. Turnbull <stephen at xemacs.org>wrote:
> 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.
> Thanks to the python community, I have learnt a lot in these mail
I didn't realize that my proposal was not backward compatible. As some of
you pointed out, currently, "return (val)" and "yield (val)" are legal
python with 'return' and 'yield' used as keywords. So, I'll withdraw my
I did want to reply to a few specific comments (e.g. 'python parser is
simple') but I don't subscribe to the mailing list and didn't want to break
the threading in the list.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas