Suggestion for "syntax error": ++i, --i

Christos TZOTZIOY Georgiou tzot at sil-tec.gr
Mon Dec 13 18:51:48 CET 2004


On Mon, 13 Dec 2004 16:42:28 +0100, rumours say that "Petr Prikryl"
<Prikryl at skil.cz> might have written:

>Summary: In my opinion, the C-like prefix
>increment and decrement operators (++i and --i)
>should be marked as "syntax error".

[snip of lots of explanations]

I am +0 on this.

However, I can imagine no *non-obscure* reasons[1] for someone to use ++
and -- as prefixes or postfixes[2], so I think that it's possible to
modify the lexer or grammar (ain't sure) to make ++ and -- without any
spaces in-between be a valid operator somehow throwing a SyntaxError.

I have been bitten by this in the beginning[3], but OTOH it didn't last
long.  I am on the plus side of 0 just because of a couple of lines of
the python Zen:

Errors should never pass silently. (although it's only a logical error)
In the face of ambiguity, refuse the temptation to guess.

my 2e-2 euros



[1] including overloaded operators and side-effects
[2] "p++ - x" is valid python even if "p++" is not
[3] at least Javascript and [ng]awk accept these operators
-- 
TZOTZIOY, I speak England very best.
"Be strict when sending and tolerant when receiving." (from RFC1958)
I really should keep that in mind when talking with people, actually...



More information about the Python-list mailing list