On Wed, Nov 9, 2016 at 12:48 PM Fleshgrinder <p...@fleshgrinder.com> wrote:
> On 11/8/2016 10:57 PM, David Walker wrote: > > I don't think that alone allows the chaining of comparisons. I'd have to > > look closer, but it'd seem to me that zend_ast_create_binary_op > > (ZEND_AST_BINARY_OP) evaluation might need to be amended as well. Seems > it > > eventually calls a `op(zval*,zval*,zval*) so the evaluated end of: one op > > would be a true/false, when comparing against another boolean op. > > > > Regardless of implementation, the core question you raised was should > > something like it exist, I'm still a strong yes on that front. I'd just > > promote introducing the left precedence and allowing the arbitrary chains > > of comparison, rather than just a single interval comparison. > > > > cheers > > -- > > Dave > > > > Yeah maybe not that easy but also not too complicated if we add > associativity to the mix. I am open for both variations and could write > up an RFC with a vote for both if desired. > > Not sure if I find the time to look into actual implementation but I > most certainly can try. > I took a quick stab at implementing, and had something working for constant expressions, but handling something akin to: $a = 2; if (1 < $a++ < 3) { ... } Is a bit awkward in our expansions of : if (1 < $a++ && $a++ < 3). Seems as if when processing the chain here, you'd need to see if the left node has a child, and somehow ensure you get the evaluated value somehow, to override the "left" node. So logically expansion of the above would be if (1 < $a++ && 3 < 3). I think the same would have too somehow handle (either by syntax error or something) that if a non-numeric value creeps into a binary-op-compare we error like: if (1 < (2==3) < 3). Just some food for thought -- Dave