Re: [PHP-DEV] [RFC] Fix the Tenary Operator -- Please!? Please?

2015-03-27 Thread Xinchen Hui
Hey:

On Fri, Mar 27, 2015 at 1:10 PM, Kris Craig kris.cr...@gmail.com wrote:
 On Thu, Mar 26, 2015 at 3:40 PM, Alain Williams a...@phcomp.co.uk wrote:

 On Thu, Mar 26, 2015 at 10:31:00PM +, Rowan Collins wrote:

  What I've always been annoyed by is the *precedence* of the operator -
 having to add brackets to mix it with string concatenation, etc - which it
 turns out to is the same in all sorts of languages.

 It is the ''all sorts of languages'' that is key here. The point is that
 PHP
 associativity for ?: is different from other languages and it is that that
 confuses and leads to bugs. What is right/wrong is not as important as all
 others doing it the other way.

 --
 Alain Williams
 Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT
 Lecturer.
 +44 (0) 787 668 0256  http://www.phcomp.co.uk/
 Parliament Hill Computers Ltd. Registration Information:
 http://www.phcomp.co.uk/contact.php
 #include std_disclaimer.h

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


 The feature freeze thing kinda rings hollow for me, as well, because we
 were debating this fairly recently before the feature freeze and we still
 got pushback from people who feared BC breakage.  This is a bug (whether
 we're calling it one or not, it is a bug) and it needs to be fixed.  PHP
 does handle it differently, yes, but the different way in which it's
 handling it is wrong.  At least, that seems to be the prevailing opinion
 among devs.

 If we don't put this in 7.0 because of the feature freeze, it needs to go
 into the next minor version if the RFC passes.  We should've pulled the
 trigger on this before the feature freeze and we shouldn't have to wait
 until 8.0 because of that.

I don't think freeze should block bug fixes...

thanks
 --Kris



-- 
Xinchen Hui
@Laruence
http://www.laruence.com/

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



Re: [PHP-DEV] [RFC] Fix the Tenary Operator -- Please!? Please?

2015-03-27 Thread Rowan Collins
On 26 March 2015 22:40:56 GMT, Alain Williams a...@phcomp.co.uk wrote:
On Thu, Mar 26, 2015 at 10:31:00PM +, Rowan Collins wrote:

 What I've always been annoyed by is the *precedence* of the operator
- having to add brackets to mix it with string concatenation, etc -
which it turns out to is the same in all sorts of languages.

It is the ''all sorts of languages'' that is key here. The point is
that PHP
associativity for ?: is different from other languages and it is that
that
confuses and leads to bugs. What is right/wrong is not as important as
all
others doing it the other way.

This reply is competely out of context to the message you quote. Yes, I know 
that the *associativity* of the operator is wrong. My contention is that in 
practice, few people ever try to associate multiple instances of the operator, 
so few bugs result from it not working.

I contrasted this with *precedence*, particularly the precedence of an 
expression mixing the ternary operator with string concatenation, which is a 
much more common thing to do. But here, PHP is doing the right thing, if 
measured by other languages doing the same.

Personally, I'd be in favour of making the operator non-associative, thus 
breaking obviously if people try it. Changing it now would result in people 
using it in PHP 7, then running the code under PHP 5 and having obscure bugs to 
fix.

Regards,
-- 
Rowan Collins
[IMSoP]



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



Re: [PHP-DEV] [RFC] Fix the Tenary Operator -- Please!? Please?

2015-03-27 Thread Rowan Collins

Michael Morris wrote on 27/03/2015 12:03:

Rowan, I seriously, seriously doubt anyone would write PHP 7 compliant code
that only takes advantage of ternary associativity, a feature that is only
occasionally useful.  If they can't take the hint from the parse errors
arising out of the spaceship op and all the other stuff being added,
they're too dumb to be programming and need to find another line of work.


I disagree. It would be perfectly easy for someone used to another 
language to be developing in a PHP 7 environment, use the idiom that's 
familiar to them (chained ternary operators as a kind of if-else 
expression), and see the results they're expecting, all without knowing 
it will work completely differently run in a PHP 5 environment.


The rest of the code might well run fine on PHP 5, since other than 
scalar type hints, there's really not that much that's changed. Do you 
really think every PHP library is suddenly going to find loads of uses 
for the spaceship operator that are so pressing they'll bump their 
minimum version requirement to 7.0?


Breaking loudly when moving between versions is always going to be 
better than behaving differently in a very hard to debug way.




While breaking backwards compatibility for its own sake is bad, avoiding it
to keep a bug in the system is worse in my opinion. And again, this is a
bug. If the way PHP associates could be used for something that would be
different, but it can't. I honestly doubt any code even exists that takes
advantage of the current behavior.


Yes, that's why I suggest non-associativity - very little current code 
will break, anyone trying to use the unavailable idiom will get instant 
feedback that it's not supported rather than unexpected behaviour.


And then later, when 8.0 rolls around, we can look at adding in the 
correct associativity, knowing for sure that no PHP 7 deployments will 
be affected.


Regards,
--
Rowan Collins
[IMSoP]

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



Re: [PHP-DEV] [RFC] Fix the Tenary Operator -- Please!? Please?

2015-03-27 Thread Chris Wright
On 26 March 2015 at 22:40, Michael Morris tendo...@gmail.com wrote:

 It's not a feature though - it's a bug.  It's just one of those bugs that
 the fixing of which may break something.


TL;DR -1 for 7, and -1 in general.

It's not really a bug, it works according to the defined behaviour, the
issue is that some (I think most) people disagree with the correctness of
the defined behaviour.

The rules are quite clear that this cannot go into 7 at this point, and no
exceptions can be made to this rule otherwise there may as well not be a
rule at all.

On the more personal level of my own opinion, I don't believe there is
enough benefit in fixing this to do it at all. It will likely break a lot
of codebases and slow down the adoption of whichever version introduces the
fix, and all it does is give people the ability to do something which
some (and again I think most) people would agree is a horrible thing to do
from a readability and maintainability perspective.

It also suffers from a similar issue to the API cleanup idea that come up
again and again - yes, some arguably poor decisions were made a long time
ago which have left us with inconsistencies and that favourite phrase of
proponents of these ideas, cognitive overhead. Fixing the inconsistencies
only serves to *add* cognitive overhead. People may not like how it works,
but at least they know how it works - and anyone writing run anywhere
code would still do what they do now, which in my experience is generally
write the ternary chain with brackets to disambiguate it, then realise it
looks horrible and change it to an elseif tree.

On Thu, Mar 26, 2015 at 6:31 PM, Rowan Collins rowan.coll...@gmail.com
 wrote:

  On 26 March 2015 20:54:12 GMT, Michael Morris tendo...@gmail.com
 wrote:
  Per PHPsadness...
  
  http://phpsadness.com/sad/30
  
  Since 7 is allowed to have BC breaks this would be the time to fix
  this.
  
  I'll let someone with more seniority actually write this up - but
  please,
  please fix this - it's a very long standing annoyance.
 
  I used to think this was a major nuisance, but recently thought about it
  and decided I've never once wanted to do this - the result is really ugly
  code whatever the associativity.
 
  What I've always been annoyed by is the *precedence* of the operator -
  having to add brackets to mix it with string concatenation, etc - which
 it
  turns out to is the same in all sorts of languages.
 
  Regards,
  --
  Rowan Collins
  [IMSoP]
 
 
 
  --
  PHP Internals - PHP Runtime Development Mailing List
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 




Re: [PHP-DEV] [RFC] Fix the Tenary Operator -- Please!? Please?

2015-03-27 Thread Michael Morris
Rowan, I seriously, seriously doubt anyone would write PHP 7 compliant code
that only takes advantage of ternary associativity, a feature that is only
occasionally useful.  If they can't take the hint from the parse errors
arising out of the spaceship op and all the other stuff being added,
they're too dumb to be programming and need to find another line of work.

While breaking backwards compatibility for its own sake is bad, avoiding it
to keep a bug in the system is worse in my opinion. And again, this is a
bug. If the way PHP associates could be used for something that would be
different, but it can't. I honestly doubt any code even exists that takes
advantage of the current behavior.

On Fri, Mar 27, 2015 at 4:57 AM, Rowan Collins rowan.coll...@gmail.com
wrote:

 On 26 March 2015 22:40:56 GMT, Alain Williams a...@phcomp.co.uk wrote:
 On Thu, Mar 26, 2015 at 10:31:00PM +, Rowan Collins wrote:
 
  What I've always been annoyed by is the *precedence* of the operator
 - having to add brackets to mix it with string concatenation, etc -
 which it turns out to is the same in all sorts of languages.
 
 It is the ''all sorts of languages'' that is key here. The point is
 that PHP
 associativity for ?: is different from other languages and it is that
 that
 confuses and leads to bugs. What is right/wrong is not as important as
 all
 others doing it the other way.

 This reply is competely out of context to the message you quote. Yes, I
 know that the *associativity* of the operator is wrong. My contention is
 that in practice, few people ever try to associate multiple instances of
 the operator, so few bugs result from it not working.

 I contrasted this with *precedence*, particularly the precedence of an
 expression mixing the ternary operator with string concatenation, which is
 a much more common thing to do. But here, PHP is doing the right thing,
 if measured by other languages doing the same.

 Personally, I'd be in favour of making the operator non-associative, thus
 breaking obviously if people try it. Changing it now would result in people
 using it in PHP 7, then running the code under PHP 5 and having obscure
 bugs to fix.

 Regards,
 --
 Rowan Collins
 [IMSoP]



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




Re: [PHP-DEV] [RFC] Fix the Tenary Operator -- Please!? Please?

2015-03-27 Thread Johannes Schlüter
On Fri, 2015-03-27 at 08:03 -0400, Michael Morris wrote:
 While breaking backwards compatibility for its own sake is bad, avoiding it
 to keep a bug in the system is worse in my opinion. And again, this is a
 bug. If the way PHP associates could be used for something that would be
 different, but it can't. I honestly doubt any code even exists that takes
 advantage of the current behavior.

What you are suggesting is not just breaking BC but Changing behavior
of code in a hard to debug way as previously working code will suddenly
start to do something else than expected probably without emitting any
error.

If you want this to run this requires a clear migration strategy for the
billions of lines of code out there.

Till this is provided please help focusing on things we can actually
improve, like testing PHP 7 to make sure it will be a stable release.

Thanks,
johannes



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



RE: [PHP-DEV] [RFC] Fix the Tenary Operator -- Please!? Please?

2015-03-27 Thread François Laupretre
 De : Xinchen Hui [mailto:larue...@php.net]
 
 I don't think freeze should block bug fixes...

Strictly speaking, not sure it can be considered as a bug. But, even if it is, 
what about bugfixes that cause BC breaks ? What is the rule ? Can we introduce 
BC breaks after feature freeze ? The question, IMO, is about the BC break, not 
whether this is a bug or not.

Regards

François



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



Re: [PHP-DEV] [RFC] Fix the Tenary Operator -- Please!? Please?

2015-03-26 Thread Kris Craig
On Thu, Mar 26, 2015 at 3:40 PM, Alain Williams a...@phcomp.co.uk wrote:

 On Thu, Mar 26, 2015 at 10:31:00PM +, Rowan Collins wrote:

  What I've always been annoyed by is the *precedence* of the operator -
 having to add brackets to mix it with string concatenation, etc - which it
 turns out to is the same in all sorts of languages.

 It is the ''all sorts of languages'' that is key here. The point is that
 PHP
 associativity for ?: is different from other languages and it is that that
 confuses and leads to bugs. What is right/wrong is not as important as all
 others doing it the other way.

 --
 Alain Williams
 Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT
 Lecturer.
 +44 (0) 787 668 0256  http://www.phcomp.co.uk/
 Parliament Hill Computers Ltd. Registration Information:
 http://www.phcomp.co.uk/contact.php
 #include std_disclaimer.h

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


The feature freeze thing kinda rings hollow for me, as well, because we
were debating this fairly recently before the feature freeze and we still
got pushback from people who feared BC breakage.  This is a bug (whether
we're calling it one or not, it is a bug) and it needs to be fixed.  PHP
does handle it differently, yes, but the different way in which it's
handling it is wrong.  At least, that seems to be the prevailing opinion
among devs.

If we don't put this in 7.0 because of the feature freeze, it needs to go
into the next minor version if the RFC passes.  We should've pulled the
trigger on this before the feature freeze and we shouldn't have to wait
until 8.0 because of that.

--Kris


Re: [PHP-DEV] [RFC] Fix the Tenary Operator -- Please!? Please?

2015-03-26 Thread Florian Margaine
Hi,

Michael Morris tendo...@gmail.com writes:

 Per PHPsadness...

 http://phpsadness.com/sad/30

 Since 7 is allowed to have BC breaks this would be the time to fix
 this.

It's too late. Feature freeze is gone.


 I'll let someone with more seniority actually write this up - but please,
 please fix this - it's a very long standing annoyance.

Cheers,

--
Florian Margaine


signature.asc
Description: PGP signature


Re: [PHP-DEV] [RFC] Fix the Tenary Operator -- Please!? Please?

2015-03-26 Thread Alex Bowers
The deadline for PHP 7 features has passed

On 26 March 2015 at 20:54, Michael Morris tendo...@gmail.com wrote:

 Per PHPsadness...

 http://phpsadness.com/sad/30

 Since 7 is allowed to have BC breaks this would be the time to fix this.

 I'll let someone with more seniority actually write this up - but please,
 please fix this - it's a very long standing annoyance.



Re: [PHP-DEV] [RFC] Fix the Tenary Operator -- Please!? Please?

2015-03-26 Thread Stanislav Malyshev
Hi!

 Since 7 is allowed to have BC breaks this would be the time to fix this.
 
 I'll let someone with more seniority actually write this up - but please,
 please fix this - it's a very long standing annoyance.

The way to do this would be to submit an RFC and put it to vote.
Unfortunately, it's too late for 7 since feature freeze date already
passed.

-- 
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] Fix the Tenary Operator -- Please!? Please?

2015-03-26 Thread Rowan Collins
On 26 March 2015 20:54:12 GMT, Michael Morris tendo...@gmail.com wrote:
Per PHPsadness...

http://phpsadness.com/sad/30

Since 7 is allowed to have BC breaks this would be the time to fix
this.

I'll let someone with more seniority actually write this up - but
please,
please fix this - it's a very long standing annoyance.

I used to think this was a major nuisance, but recently thought about it and 
decided I've never once wanted to do this - the result is really ugly code 
whatever the associativity.

What I've always been annoyed by is the *precedence* of the operator - having 
to add brackets to mix it with string concatenation, etc - which it turns out 
to is the same in all sorts of languages.

Regards,
-- 
Rowan Collins
[IMSoP]



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



Re: [PHP-DEV] [RFC] Fix the Tenary Operator -- Please!? Please?

2015-03-26 Thread Alain Williams
On Thu, Mar 26, 2015 at 10:31:00PM +, Rowan Collins wrote:

 What I've always been annoyed by is the *precedence* of the operator - having 
 to add brackets to mix it with string concatenation, etc - which it turns out 
 to is the same in all sorts of languages.

It is the ''all sorts of languages'' that is key here. The point is that PHP
associativity for ?: is different from other languages and it is that that
confuses and leads to bugs. What is right/wrong is not as important as all
others doing it the other way.

-- 
Alain Williams
Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT 
Lecturer.
+44 (0) 787 668 0256  http://www.phcomp.co.uk/
Parliament Hill Computers Ltd. Registration Information: 
http://www.phcomp.co.uk/contact.php
#include std_disclaimer.h

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



Re: [PHP-DEV] [RFC] Fix the Tenary Operator -- Please!? Please?

2015-03-26 Thread Michael Morris
It's not a feature though - it's a bug.  It's just one of those bugs that
the fixing of which may break something.

On Thu, Mar 26, 2015 at 6:31 PM, Rowan Collins rowan.coll...@gmail.com
wrote:

 On 26 March 2015 20:54:12 GMT, Michael Morris tendo...@gmail.com wrote:
 Per PHPsadness...
 
 http://phpsadness.com/sad/30
 
 Since 7 is allowed to have BC breaks this would be the time to fix
 this.
 
 I'll let someone with more seniority actually write this up - but
 please,
 please fix this - it's a very long standing annoyance.

 I used to think this was a major nuisance, but recently thought about it
 and decided I've never once wanted to do this - the result is really ugly
 code whatever the associativity.

 What I've always been annoyed by is the *precedence* of the operator -
 having to add brackets to mix it with string concatenation, etc - which it
 turns out to is the same in all sorts of languages.

 Regards,
 --
 Rowan Collins
 [IMSoP]



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