Re: [PHP-DEV] [RFC] Interval Comparison

2016-11-12 Thread David Walker
On Sat, Nov 12, 2016 at 9:47 AM Christoph M. Becker wrote: > On 12.11.2016 at 17:21, David Walker wrote: > > > Should > > $a = 1; > > var_dump(1 < $a++ < 3); > > > > (expanded into numbers) be evaluated as: > > 1 < 2 && 2 < 3 - True > > or > > 1 < 2 && 3 < 3 - False > > In my

Re: [PHP-DEV] [RFC] Interval Comparison

2016-11-12 Thread Christoph M. Becker
On 12.11.2016 at 17:21, David Walker wrote: > Should > $a = 1; > var_dump(1 < $a++ < 3); > > (expanded into numbers) be evaluated as: > 1 < 2 && 2 < 3 - True > or > 1 < 2 && 3 < 3 - False In my opinion, that should evaluate to 1 < 1 // false because we have a post-increment operator, and it

Re: [PHP-DEV] [RFC] Interval Comparison

2016-11-12 Thread Kris Craig
On Nov 12, 2016 8:21 AM, "David Walker" wrote: > > On Sat, Nov 12, 2016 at 3:08 AM Lauri Kenttä wrote: > > > On 2016-11-11 19:03, David Walker wrote: > > > > > > I took a quick stab at implementing, and had something working for > > > constant

Re: [PHP-DEV] [RFC] Interval Comparison

2016-11-12 Thread David Walker
On Sat, Nov 12, 2016 at 3:08 AM Lauri Kenttä wrote: > On 2016-11-11 19:03, David Walker wrote: > > > > 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) { > >

Re: [PHP-DEV] [RFC] Interval Comparison

2016-11-12 Thread Lauri Kenttä
On 2016-11-11 19:03, David Walker wrote: 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

Re: [PHP-DEV] [RFC] Interval Comparison

2016-11-11 Thread Fleshgrinder
On 11/11/2016 6:03 PM, David Walker wrote: > 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

Re: [PHP-DEV] [RFC] Interval Comparison

2016-11-11 Thread David Walker
On Wed, Nov 9, 2016 at 12:48 PM Fleshgrinder 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)

Re: [PHP-DEV] [RFC] Interval Comparison

2016-11-09 Thread Andrea Faulds
Hi, Fleshgrinder wrote: That change would actually be brutally easy since we only need to change the `%nonassoc` to `%left` and we are done. Not quite. We'd still need to parse and compile these expressions correctly. If we just add associativity, then we end up with Java's behaviour. --

Re: [PHP-DEV] [RFC] Interval Comparison

2016-11-09 Thread Fleshgrinder
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

Re: [PHP-DEV] [RFC] Interval Comparison

2016-11-08 Thread David Walker
On Tue, Nov 8, 2016 at 12:34 PM Fleshgrinder wrote: > This requires associativity, as Python has it. > > https://docs.python.org/3/reference/expressions.html#comparisons > > The problem, as explained in the Python reference, is that in `x < y < > z` the variables `x` and

Re: [PHP-DEV] [RFC] Interval Comparison

2016-11-08 Thread Fleshgrinder
On 11/7/2016 10:51 PM, David Walker wrote: > Sense be damed ;-) . I'd attribute it to an identity of sorts (if it was > to go all out with comparison chaining). Yes it makes little sense, in > practice, but the truth of it would be the same. > > I realize that my comment, and question were going

Re: [PHP-DEV] [RFC] Interval Comparison

2016-11-08 Thread Lauri Kenttä
On 2016-11-07 23:51, David Walker wrote: On Mon, Nov 7, 2016 at 1:38 PM Fleshgrinder wrote: We are only extending binary to ternary for <= and <. I realize that my comment, and question were going a bit off-topic with going on about the chaining of comparisons, but I'm

Re: [PHP-DEV] [RFC] Interval Comparison

2016-11-07 Thread David Walker
On Mon, Nov 7, 2016 at 1:38 PM Fleshgrinder wrote: > Hey guys! :) The first one should definitely be an error since it makes no sense. Sense be damed ;-) . I'd attribute it to an identity of sorts (if it was to go all out with comparison chaining). Yes it makes little

Re: [PHP-DEV] [RFC] Interval Comparison

2016-11-06 Thread David Walker
On Sun, Nov 6, 2016 at 1:59 PM David Rodrigues wrote: > I guess that the biggest problem is about the code parsing. Currently PHP > should supports what you wrote, but with another meaning. And personally I > think that this feature is not too common on programming

Re: [PHP-DEV] [RFC] Interval Comparison

2016-11-06 Thread David Rodrigues
I guess that the biggest problem is about the code parsing. Currently PHP should supports what you wrote, but with another meaning. And personally I think that this feature is not too common on programming language in general, once that it is possible from first format (maybe more clear too). Em

[PHP-DEV] [RFC] Interval Comparison

2016-11-06 Thread Fleshgrinder
Validating whether a number is within a closed or open interval is currently possible only via a construct like the following: ``` if (0 < $x && $x < 42) { echo 'x is in (0, 42)'; } if (0 <= $x && $x <= 42) { echo 'x is in [0, 42]'; } ``` It is not very readable and repetitive. It would