On 17 November 2015 at 14:49, Donald Stufft <don...@stufft.io> wrote:
...
>> ('name', [], [], (('posix', '==', 'dud'), [('and', ('posix', '==',
>> 'odd')), ('or', ('posix', '==', 'fred'))]))
>>
>> which can just be rolled up left to right.
>
> Should we use the same rules as Python in order to maintain compatibility or 
> is there a compelling reason to break compatibility here?

So for clarity:
True and -> right hand side evaluated stand alone
False and -> False
True or -> True
False or -> right hand side evaluated stand alone

We can roll that up using the parse tree:
(('posix', '==', 'dud'), [('and', ('posix', '==', 'odd')), ('or',
('posix', '==', 'fred'))]))
evaluate the start to get a 'result'
pop an expression from the beginning of the list giving opcode, next.
lookup (result, opcode) in the above truth table, giving one of True,
False, None
on None, result = next and loop.
on True or False, return that.

So - no reason to break compat, though the grammar could perhaps be
tweaked if we want to write an inline evaluator. The same expressions
would be accepted either way. I think its worth copying the Python
rules into the PEP though for clarity.

-Rob



-- 
Robert Collins <rbtcoll...@hp.com>
Distinguished Technologist
HP Converged Cloud
_______________________________________________
Distutils-SIG maillist  -  Distutils-SIG@python.org
https://mail.python.org/mailman/listinfo/distutils-sig

Reply via email to