
On Sat, Apr 27, 2013 at 1:45 PM, Daniel Holth <dholth@gmail.com> wrote:
How do you feel about parenthesis?
Without them, you have to express everything in DNF (disjunctive normal form), which usually means a lot of subexpression duplication when you want to express something like "(a or b) and (c or d)"; it would otherwise expand to: "a and c or a and d or b and c or b and d"... assuming I didn't make an error in the expansion. ;-) (Also, it's much harder to read and interpret correctly, even with such a relatively simple expression, and is absolutely not DRY.)
It's probably not that hard to prohibit chained comparisons. Do we need an abnf?
Maybe. If so, I would use a subset of the actual Python grammar, since it would help in translation for implementations that abuse Python's parser as part of the evaluation process. (Which is all of them, at the moment: distlib uses Python 2.6+'s "ast" module, while my work on setuptools is using the "parser" module, which is available in at least 2.3 through 3.2.)
What's wrong with eval?
It's slow, and prompts some people to be paranoid about whether you're thereby introducing some sort of to-be-discovered-in-future security hole. In truth, I've realized that I can do away with it entirely, anyway; the last usage I had was for string constants, but you can actually just strip off the quotes. Using eval was just a way to do that without needing to examine what kinds of quotes, decode escapes, etc.