Attitude about new keywords
sjmachin at lexicon.net
Sun Feb 9 10:31:38 CET 2003
David Eppstein <eppstein at ics.uci.edu> wrote in message news:<eppstein-2A7B3E.14172808022003 at news.service.uci.edu>...
> In article <7x1y2is9qt.fsf at ruckus.brouhaha.com>,
> Paul Rubin <phr-n2003b at NOSPAMnightsong.com> wrote:
> > I'd like to ask a meta-question about this: why is adding new keywords
> > something to be so urgently avoided?
> Because it can make previously-working code stop working, when the new
> keyword happens to match somebody's variable name.
I should preface my questions/remarks by saying that I know nothing
about parsing the Python grammar, nor how restrictive the definition
of "keyword" is.
It is easy to see that what David says is correct, in the case of a
keyword that starts a statement --- a recent example of such a new
keyword would be "yield". This would cause grief for people who had a
variable called "yield" (e.g. the yield on an investment).
However I don't see the problem with introducing "then" as in the
conditional expression "if condition then expr1 else expr2". A
variable name cannot legally appear in that position in Python. If
anyone did have a variable named "then" (far less likely than "yield";
variable names tend to be noun, verb, adjective, and "then" is not one
of these (in English, at least)) cannot the compiler handle the
following, or is it much more difficult?
then = 1.5
result = 42 + if some_cond then func1(x) else func2(x)
More information about the Python-list