Re: [PHP-DEV] [RFC] Deprecate left-associative ternary operator

2019-04-24 Thread Sara Golemon
On Wed, Apr 24, 2019 at 6:48 PM Christoph M. Becker 
wrote:

> On 24.04.2019 at 19:25, Sara Golemon wrote:
>
> > On Tue, Apr 23, 2019 at 3:56 AM Nikita Popov 
> wrote:
> >
> >> 20 years of code in the wild has not "accepted that fact and moved on".
> If
> >> a left-associative ternary is used, it is almost certainly a bug. If
> people
> >> use this structure by accident (because it is familiar from other
> >> programming languages), I'd like them to get an error instead of having
> to
> >> figure out why their obviously correct code is not working or, in the
> worse
> >> case, just leave behind buggy code.
> >
> > I'm on dismal wifi at the moment, else I'd do some searches, but do you
> > have any examples of code in the wild subject to this bug?
> > I agree it's a lousy state, but it's not emergent.
>
> See .
>
>  Okay, so the most compelling part for me in this analysis is the fact
that Symfony and ZF have issues.  I can shrug off a lot of questionable PHP
coders, but i have to acknowledge major frameworks stumbling on this gotcha.

Convinced.
+1

-Sara


Re: [PHP-DEV] [RFC] Deprecate left-associative ternary operator

2019-04-24 Thread Christoph M. Becker
On 24.04.2019 at 19:25, Sara Golemon wrote:

> On Tue, Apr 23, 2019 at 3:56 AM Nikita Popov  wrote:
>
>> 20 years of code in the wild has not "accepted that fact and moved on". If
>> a left-associative ternary is used, it is almost certainly a bug. If people
>> use this structure by accident (because it is familiar from other
>> programming languages), I'd like them to get an error instead of having to
>> figure out why their obviously correct code is not working or, in the worse
>> case, just leave behind buggy code.
>
> I'm on dismal wifi at the moment, else I'd do some searches, but do you
> have any examples of code in the wild subject to this bug?
> I agree it's a lousy state, but it's not emergent.

See .

--
Christoph M. Becker

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] [RFC] Deprecate left-associative ternary operator

2019-04-24 Thread Sara Golemon
On Wed, Apr 24, 2019 at 1:56 PM M. W. Moe  wrote:

> until this RCF does not happen; I would say nothing interesting will ever
> happen.
>
> Please, Reality TV is less hyperbolic than that.
JIT isn't interesting?
Typed Properties isn't interesting?
FFI isn't interesting?
 Preload isn't interesting?

Pack it up, folks!  Nothing we're doing here is interesting or ever will
be, because the associativity of the ternary operator is wrong.

-Sara


Re: [PHP-DEV] [RFC] Deprecate left-associative ternary operator

2019-04-24 Thread M. W. Moe
Hello,

the underlaying discussion here is more important; than just voting yes or
no on uncompleted hamiltonian graphs; the real question here does php8 will
be a break thru; meaning bugger off the mistakes of the past or a
continuation of them; until this RCF does not happen; I would say nothing
interesting will ever happen.

Have a good day.

On Wed, Apr 24, 2019 at 10:25 AM Sara Golemon  wrote:

> On Tue, Apr 23, 2019 at 3:56 AM Nikita Popov  wrote:
>
> > Can't say I understand your position here. Don't want to change the
> > ternary from left-associative to right-associative? I can understand
> that:
> > Silent behavior changes are always problematic. This is not what the RFC
> > proposes though.
> >
> > Did the RFC change since introduction? I may have been looking at a stale
> load of the page (opened it up awhile ago and only just got around to
> responding).
>
> As for what it says atm, I still think it goes too far.  the warning in 7.4
> I can support, but I'm not a fan of breaking existing code on a feature
> that's this old. Ratchet up the warning in 8.0 if you'd like, but error is
> further than I'm willing to go on this one.
>
>
> > 20 years of code in the wild has not "accepted that fact and moved on".
> If
> > a left-associative ternary is used, it is almost certainly a bug. If
> people
> > use this structure by accident (because it is familiar from other
> > programming languages), I'd like them to get an error instead of having
> to
> > figure out why their obviously correct code is not working or, in the
> worse
> > case, just leave behind buggy code.
> >
> > I'm on dismal wifi at the moment, else I'd do some searches, but do you
> have any examples of code in the wild subject to this bug?
> I agree it's a lousy state, but it's not emergent.
>
> -Sara
>


Re: [PHP-DEV] [RFC] Deprecate left-associative ternary operator

2019-04-24 Thread Sara Golemon
On Tue, Apr 23, 2019 at 3:56 AM Nikita Popov  wrote:

> Can't say I understand your position here. Don't want to change the
> ternary from left-associative to right-associative? I can understand that:
> Silent behavior changes are always problematic. This is not what the RFC
> proposes though.
>
> Did the RFC change since introduction? I may have been looking at a stale
load of the page (opened it up awhile ago and only just got around to
responding).

As for what it says atm, I still think it goes too far.  the warning in 7.4
I can support, but I'm not a fan of breaking existing code on a feature
that's this old. Ratchet up the warning in 8.0 if you'd like, but error is
further than I'm willing to go on this one.


> 20 years of code in the wild has not "accepted that fact and moved on". If
> a left-associative ternary is used, it is almost certainly a bug. If people
> use this structure by accident (because it is familiar from other
> programming languages), I'd like them to get an error instead of having to
> figure out why their obviously correct code is not working or, in the worse
> case, just leave behind buggy code.
>
> I'm on dismal wifi at the moment, else I'd do some searches, but do you
have any examples of code in the wild subject to this bug?
I agree it's a lousy state, but it's not emergent.

-Sara


Re: [PHP-DEV] [RFC] Deprecate left-associative ternary operator

2019-04-24 Thread Claude Pache



> Le 24 avr. 2019 à 11:10, Björn Larsson  a écrit :
> 
> Den 2019-04-22 kl. 10:09, skrev Nikita Popov:
>> On Tue, Apr 9, 2019 at 11:54 AM Nikita Popov  wrote:
>> 
>>> Hi internals,
>>> The only objection here came from Gabriel, and I don't think we'll come to
>>> an agreement.
>>> Inspired by Bob's recent RFC for concat precedence, I'd like to propose a
>>> deprecation and removal of the left-associative behavior of ternaries.
>>> Instead, explicit parentheses should be used:
>>> 
>>> https://wiki.php.net/rfc/ternary_The only objection here came from
>>> Gabriel, and I don't think we'll come to an agreement.associativity
>>> 
>>> 
>>> This RFC makes nested ternaries without disambiguating parentheses an
>>> error in PHP 8 -- we might want to consider making them right-associative
>>> instead, which is both useful and matches the behavior of other languages.
>>> 
>>> Regards,
>>> Nikita
>>> 
>> Heads up: Plan to start voting tomorrow.
>> 
>> Apart from Bishop, would anyone else prefer to directly go to right
>> associativity in PHP 8 rather than making it an error? I'm rather partial
>> to that myself, maybe it can be included as a voting option...
>> 
>> Nikita
> 
> Hi,
> 
> I think one should go for the right associativity. 8.x is the right place to
> do it, if at all. Doing it directly in 8.0 has the benefit that when upgrading
> to a major version it justifies an upgrading project for an application and
> one also might get tool support, e.g. the php7mar tool for 7.0 was quite
> valuable. Also IDEs like phpstorm has good support.
> 
> One then has to weigh legacy code versus new code being written with a
> behaviour different from almost all other languages. I'm not sure if this
> is an appropriate example to compare with, but I came to think on the
> PHP 7.0 Uniform Variable Syntax rfc regarding migration effort and BC
> impact.
> 
> r//Björn L
> 
> -- 
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

If you go for right-associative straight in PHP 8, you make it mandatory to use 
a static analysis tool for:

* migrating code from one major version to the next;
* maintaining a library that aims to run in two major consecutive versions.

Although that might be a no-brainer for anyone following internals, I doubt it 
is the case for anyone writing PHP.

With a more step-wise approach (left-associative in PHP 7, non-associative in 
PHP 8, right-associative in PHP 9 or 10), the situation is much safer and 
simpler: you can’t even compile the code in at least one of the consecutive 
major versions you aim to support, and the error message says exactly what and 
where you have to fix in order to make it working.

As says an Italian proverb: chi va piano, va sano e lontano.

—Claude



--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] [RFC] Deprecate left-associative ternary operator

2019-04-23 Thread Nikita Popov
On Mon, Apr 22, 2019 at 5:28 PM Sara Golemon  wrote:

> On Tue, Apr 9, 2019 at 4:54 AM Nikita Popov  wrote:
>
>> Inspired by Bob's recent RFC for concat precedence, I'd like to propose a
>> deprecation and removal of the left-associative behavior of ternaries.
>> Instead, explicit parentheses should be used:
>>
>> https://wiki.php.net/rfc/ternary_associativity
>>
>> This RFC makes nested ternaries without disambiguating parentheses an
>> error
>> in PHP 8 -- we might want to consider making them right-associative
>> instead, which is both useful and matches the behavior of other languages.
>>
>> Sorry, but I'm a "No" on this one.
>
> It'd be swell if PHP's ternary matched other languages, but it doesn't,
> and we have 20 years of code in the wild which has accepted that fact and
> moved on.  I don't see the benefit in breaking that code. Advise the use of
> parentheses and move on.
>

Can't say I understand your position here. Don't want to change the ternary
from left-associative to right-associative? I can understand that: Silent
behavior changes are always problematic. This is not what the RFC proposes
though.

20 years of code in the wild has not "accepted that fact and moved on". If
a left-associative ternary is used, it is almost certainly a bug. If people
use this structure by accident (because it is familiar from other
programming languages), I'd like them to get an error instead of having to
figure out why their obviously correct code is not working or, in the worse
case, just leave behind buggy code.

Nikita


Re: [PHP-DEV] [RFC] Deprecate left-associative ternary operator

2019-04-22 Thread Stanislav Malyshev
Hi!

> It'd be swell if PHP's ternary matched other languages, but it doesn't, and
> we have 20 years of code in the wild which has accepted that fact and moved
> on.  I don't see the benefit in breaking that code. Advise the use of
> parentheses and move on.

Exactly.

-- 
Stas Malyshev
smalys...@gmail.com

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] [RFC] Deprecate left-associative ternary operator

2019-04-22 Thread Sara Golemon
On Tue, Apr 9, 2019 at 4:54 AM Nikita Popov  wrote:

> Inspired by Bob's recent RFC for concat precedence, I'd like to propose a
> deprecation and removal of the left-associative behavior of ternaries.
> Instead, explicit parentheses should be used:
>
> https://wiki.php.net/rfc/ternary_associativity
>
> This RFC makes nested ternaries without disambiguating parentheses an error
> in PHP 8 -- we might want to consider making them right-associative
> instead, which is both useful and matches the behavior of other languages.
>
> Sorry, but I'm a "No" on this one.

It'd be swell if PHP's ternary matched other languages, but it doesn't, and
we have 20 years of code in the wild which has accepted that fact and moved
on.  I don't see the benefit in breaking that code. Advise the use of
parentheses and move on.

-Sara


Re: [PHP-DEV] [RFC] Deprecate left-associative ternary operator

2019-04-17 Thread Nikita Popov
On Sun, Apr 14, 2019 at 12:12 AM Lauri Kenttä 
wrote:

> On 2019-04-09 12:54, Nikita Popov wrote:
> > Inspired by Bob's recent RFC for concat precedence, I'd like to propose
> > a
> > deprecation and removal of the left-associative behavior of ternaries.
> > Instead, explicit parentheses should be used: ...
>
> What about nesting in the middle part: 1 ? 2 ? 3 : 4 : 5
> This is unambiguous and should be allowed IMO.
>

This case is not affected, as it's not related to associativity. I've
mentioned this in the RFC explicitly now.

Nikita


Re: [PHP-DEV] [RFC] Deprecate left-associative ternary operator

2019-04-13 Thread Lauri Kenttä

On 2019-04-09 12:54, Nikita Popov wrote:
Inspired by Bob's recent RFC for concat precedence, I'd like to propose 
a

deprecation and removal of the left-associative behavior of ternaries.
Instead, explicit parentheses should be used: ...


What about nesting in the middle part: 1 ? 2 ? 3 : 4 : 5
This is unambiguous and should be allowed IMO.

--
Lauri Kenttä

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] [RFC] Deprecate left-associative ternary operator

2019-04-10 Thread Björn Larsson

Den 2019-04-09 kl. 11:54, skrev Nikita Popov:

Hi internals,

Inspired by Bob's recent RFC for concat precedence, I'd like to propose a
deprecation and removal of the left-associative behavior of ternaries.
Instead, explicit parentheses should be used:

https://wiki.php.net/rfc/ternary_associativity

This RFC makes nested ternaries without disambiguating parentheses an error
in PHP 8 -- we might want to consider making them right-associative
instead, which is both useful and matches the behavior of other languages.

Regards,
Nikita

Thanks for bringing this up. I recall it was up for discussion in
PHP 7.0, never made it then. Hope it does it now!

Should one in the RFC reference this bug report from 2012?
- https://bugs.php.net/bug.php?id=61915

r//Björn L

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] [RFC] Deprecate left-associative ternary operator

2019-04-10 Thread Claude Pache



> Le 10 avr. 2019 à 21:21, Stanislav Malyshev  a écrit :
> 
> Hi!
> 
>> Inspired by Bob's recent RFC for concat precedence, I'd like to propose a
>> deprecation and removal of the left-associative behavior of ternaries.
>> Instead, explicit parentheses should be used:
>> 
>> https://wiki.php.net/rfc/ternary_associativity
> 
> Please, let's not mess with language syntax and require people to
> rewrite their code just because suddenly after 20 years of existence in
> the language we feel maybe the precedence should be different. I
> literally can't think of a single case where it would improve anyone's
> life in any substantial way.

I bet that more than one developer has once written , and later has wasted a nontrivial amount of time in 
order to understand why they got some wrong result. So, definitely, making that 
trap a syntax error is a real tangible improvement of the language. 

> If you wanted to use parentheses, you can
> do it now - you can even have it enforced by code analyzer if you wish
> so, in your private code base.

A language that requires their users to use a code analyser (or to read the 
manual thoroughly before starting to code) in order to keep their sanity, well, 
... has a problem. 
 
> But I can easily imagine dealing with
> tons of deprecation warnings (which usually break CI unit tests and
> wreak general havoc) or even worse, useless errors, in existing code,
> which would become broken for no reason

As I can’t imagine a case where someone would have taken advantage of the 
current left-associativity semantics, I can’t imagine either someone dealing 
with “a ton of deprecation warnings” because of that. But TBH, my imagination 
is sometimes very selective. However, what I can imagine, is that hidden bugs 
will be revealed as a side-effect of those deprecation warnings, and time will 
be taken to understand and correct them. 

—Claude

> but... honestly, I don't even
> know how to finish this phrase, I can't even think of a single reason I
> could explain to anybody why their code would no longer work in 8.0.
> 
> I understand 8.0 is a good target for breaking things. But that doesn't
> mean we have to do it as much as possible.
> 
> And this absolutely doesn't mean we need to get 7.4 to break things (and
> yes, deprecation warning is breaking things, in most cases).
> -- 
> Stas Malyshev
> smalys...@gmail.com
> 
> -- 
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] [RFC] Deprecate left-associative ternary operator

2019-04-10 Thread Levi Morrison
On Wed, Apr 10, 2019 at 1:22 PM Stanislav Malyshev  wrote:
>
> Hi!
>
> > Inspired by Bob's recent RFC for concat precedence, I'd like to propose a
> > deprecation and removal of the left-associative behavior of ternaries.
> > Instead, explicit parentheses should be used:
> >
> > https://wiki.php.net/rfc/ternary_associativity
>
> Please, let's not mess with language syntax and require people to
> rewrite their code just because suddenly after 20 years of existence in
> the language we feel maybe the precedence should be different. I
> literally can't think of a single case where it would improve anyone's
> life in any substantial way. If you wanted to use parentheses, you can
> do it now - you can even have it enforced by code analyzer if you wish
> so, in your private code base. But I can easily imagine dealing with
> tons of deprecation warnings (which usually break CI unit tests and
> wreak general havoc) or even worse, useless errors, in existing code,
> which would become broken for no reason but... honestly, I don't even
> know how to finish this phrase, I can't even think of a single reason I
> could explain to anybody why their code would no longer work in 8.0.
>
> I understand 8.0 is a good target for breaking things. But that doesn't
> mean we have to do it as much as possible.
>
> And this absolutely doesn't mean we need to get 7.4 to break things (and
> yes, deprecation warning is breaking things, in most cases).
> --
> Stas Malyshev
> smalys...@gmail.com
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php

We do not consider new warnings, including deprecation notices, as
breaking changes. We know that due to error handlers it can have an
effect, but it's just part of the process.

I disagree with Stas on the value. The precedence is wrong, and I know
of a few codebases which had bugs due to this. In every case, the fix
was to avoid it altogether. I agree with statement from the RFC:

> As left-associative ternaries are almost certainly bugs, the impact of this 
> change should be minimal.

Thanks, Nikita, on putting this together. It's definitely not a "fun" RFC.

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] [RFC] Deprecate left-associative ternary operator

2019-04-10 Thread Michael Wallner
Nikita Popov  schrieb am Di., 9. Apr. 2019, 11:54:

> Hi internals,
>
> Inspired by Bob's recent RFC for concat precedence, I'd like to propose a
> deprecation and removal of the left-associative behavior of ternaries.
> Instead, explicit parentheses should be used:
>
> https://wiki.php.net/rfc/ternary_associativity
>
> This RFC makes nested ternaries without disambiguating parentheses an error
> in PHP 8 -- we might want to consider making them right-associative
> instead, which is both useful and matches the behavior of other languages.
>
> Regards,
> Nikita
>

Simple, +1.

Regards,
Mike


Re: [PHP-DEV] [RFC] Deprecate left-associative ternary operator

2019-04-10 Thread Stanislav Malyshev
Hi!

> Inspired by Bob's recent RFC for concat precedence, I'd like to propose a
> deprecation and removal of the left-associative behavior of ternaries.
> Instead, explicit parentheses should be used:
> 
> https://wiki.php.net/rfc/ternary_associativity

Please, let's not mess with language syntax and require people to
rewrite their code just because suddenly after 20 years of existence in
the language we feel maybe the precedence should be different. I
literally can't think of a single case where it would improve anyone's
life in any substantial way. If you wanted to use parentheses, you can
do it now - you can even have it enforced by code analyzer if you wish
so, in your private code base. But I can easily imagine dealing with
tons of deprecation warnings (which usually break CI unit tests and
wreak general havoc) or even worse, useless errors, in existing code,
which would become broken for no reason but... honestly, I don't even
know how to finish this phrase, I can't even think of a single reason I
could explain to anybody why their code would no longer work in 8.0.

I understand 8.0 is a good target for breaking things. But that doesn't
mean we have to do it as much as possible.

And this absolutely doesn't mean we need to get 7.4 to break things (and
yes, deprecation warning is breaking things, in most cases).
-- 
Stas Malyshev
smalys...@gmail.com

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] [RFC] Deprecate left-associative ternary operator

2019-04-09 Thread Rowan Collins
On Tue, 9 Apr 2019 at 11:19, Bishop Bettini  wrote:

> See also Bug 61915[1], which suggests leaving ? left and introducing ?? for
> right. Personally I don't see any benefit to keeping a ternary with left
> associativity.
>


?? wouldn't work, because that's now the null-coalescing operator. (I've no
idea if it would be ambiguous to the parser to have it mean both, but it
would be horrible for humans to read!)

Obviously, that doesn't rule out having a new syntax of some sort, but it
highlights the usual problem with suggesting new operators: we're running
out of punctuation!

Regards,
-- 
Rowan Collins
[IMSoP]


Re: [PHP-DEV] [RFC] Deprecate left-associative ternary operator

2019-04-09 Thread Gabriel O
Hello, I am interested to know if this affects behaviour of following code:

putenv($this->colSize ? 'COLUMNS' : 'COLUMNS='.$this->colSize);

> On 9. Apr 2019, at 11:54, Nikita Popov  wrote:
> 
> Hi internals,
> 
> Inspired by Bob's recent RFC for concat precedence, I'd like to propose a
> deprecation and removal of the left-associative behavior of ternaries.
> Instead, explicit parentheses should be used:
> 
> https://wiki.php.net/rfc/ternary_associativity
> 
> This RFC makes nested ternaries without disambiguating parentheses an error
> in PHP 8 -- we might want to consider making them right-associative
> instead, which is both useful and matches the behavior of other languages.
> 
> Regards,
> Nikita


-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] [RFC] Deprecate left-associative ternary operator

2019-04-09 Thread Rowan Collins
On Tue, 9 Apr 2019 at 10:54, Nikita Popov  wrote:

> Hi internals,
>
> Inspired by Bob's recent RFC for concat precedence, I'd like to propose a
> deprecation and removal of the left-associative behavior of ternaries.
> Instead, explicit parentheses should be used:
>
> https://wiki.php.net/rfc/ternary_associativity
>


Thanks for putting this forward, it removes one more WTF from the language.
I think non-associativity is safest, because even if it's rarely desirable,
code may be out there that works accidentally with the current situation.
There's also the risk that someone would get used to it working one way in
PHP 8, and accidentally use it in code that's still deployed on PHP 7.

In both cases, it's better to generate an error and force users to be
explicit than introduce subtle bugs. We can then look at making it
right-associative in PHP 9, because anybody that needs to support 7, 8 and
9 can be explicit, and hopefully not many people will be jumping directly
between 7 and 9.

Regards,
-- 
Rowan Collins
[IMSoP]


Re: [PHP-DEV] [RFC] Deprecate left-associative ternary operator

2019-04-09 Thread Bishop Bettini
On Tue, Apr 9, 2019 at 5:54 AM Nikita Popov  wrote:

>
> Inspired by Bob's recent RFC for concat precedence, I'd like to propose a
> deprecation and removal of the left-associative behavior of ternaries.
> Instead, explicit parentheses should be used:
>
> https://wiki.php.net/rfc/ternary_associativity
>
> This RFC makes nested ternaries without disambiguating parentheses an error
> in PHP 8 -- we might want to consider making them right-associative
> instead, which is both useful and matches the behavior of other languages.
>

I'd support mandatory disambiguation, though I feel we should go all in and
introduce a ternary with right associativity.

See also Bug 61915[1], which suggests leaving ? left and introducing ?? for
right. Personally I don't see any benefit to keeping a ternary with left
associativity.

[1]: https://bugs.php.net/bug.php?id=61915


[PHP-DEV] [RFC] Deprecate left-associative ternary operator

2019-04-09 Thread Nikita Popov
Hi internals,

Inspired by Bob's recent RFC for concat precedence, I'd like to propose a
deprecation and removal of the left-associative behavior of ternaries.
Instead, explicit parentheses should be used:

https://wiki.php.net/rfc/ternary_associativity

This RFC makes nested ternaries without disambiguating parentheses an error
in PHP 8 -- we might want to consider making them right-associative
instead, which is both useful and matches the behavior of other languages.

Regards,
Nikita