Re: [PHP-DEV] [RFC] Implicit isset() in Shorthand Ternary Operator

2014-09-18 Thread Gwynne Raskind
On Sep 17, 2014, at 11:40, Matthew Fonda mfo...@php.net wrote: Hi Andrea, This is great -- thanks to you and Nikita for the work here. Syntax wise, I would prefer a function-like syntax, e.g. coalesce($a, $b, 'c') or ifsetor() instead of $a ?? $b ?? 'c'. I find this more readable, and it

Re: [PHP-DEV] [RFC] Implicit isset() in Shorthand Ternary Operator

2014-09-18 Thread Pete Boere
I'm seeing '??' as analogous to the way JS developers use '||', and I use that all the time when writing JS. Personally I wouldn't be interested in a function version because the short-circuiting of '??' is an important distinction; not something you can replicate with a function. Therefore

Re: [PHP-DEV] [RFC] Implicit isset() in Shorthand Ternary Operator

2014-09-18 Thread Andrea Faulds
On 18 Sep 2014, at 12:32, Pete Boere p...@the-echoplex.net wrote: I'm seeing '??' as analogous to the way JS developers use '||', and I use that all the time when writing JS. PHP already has a direct equivalent to ||, namely the ?: operator. However, unfortunately PHP always spits out a

Re: [PHP-DEV] [RFC] Implicit isset() in Shorthand Ternary Operator

2014-09-18 Thread Rowan Collins
Pete Boere wrote (on 18/09/2014): I'm seeing '??' as analogous to the way JS developers use '||', and I use that all the time when writing JS. Actually, JS's || is more analogous to the existing ?: operator, because it checks for truthiness, not definedness (!empty() rather than isset(), in

Re: [PHP-DEV] [RFC] Implicit isset() in Shorthand Ternary Operator

2014-09-18 Thread Johannes Schlüter
On Thu, 2014-09-18 at 12:41 +0100, Andrea Faulds wrote: We could use a function *syntax*, though, but I don’t like this idea. coalesce() and ifsetor() are both ugly to me, and it’s not super obvious what they do: var_dump(coalesce($_GET[‘foobar’], 3)); vs.

Re: [PHP-DEV] [RFC] Implicit isset() in Shorthand Ternary Operator

2014-09-18 Thread Chris Wright
On 18 September 2014 14:34, Johannes Schlüter johan...@schlueters.de wrote: On Thu, 2014-09-18 at 12:41 +0100, Andrea Faulds wrote: We could use a function *syntax*, though, but I don’t like this idea. coalesce() and ifsetor() are both ugly to me, and it’s not super obvious what they do:

Re: [PHP-DEV] [RFC] Implicit isset() in Shorthand Ternary Operator

2014-09-18 Thread Adrian Guenter
On Sep 18, 2014 9:36 AM, Johannes Schlüter johan...@schlueters.de wrote: On Thu, 2014-09-18 at 12:41 +0100, Andrea Faulds wrote: We could use a function *syntax*, though, but I don’t like this idea. coalesce() and ifsetor() are both ugly to me, and it’s not super obvious what they do:

Re: [PHP-DEV] [RFC] Implicit isset() in Shorthand Ternary Operator

2014-09-17 Thread Sara Golemon
On Sep 16, 2014, at 13:46, Kingsquare.nl - Robin Speekenbrink ro...@kingsquare.nl wrote: As a userland point of view on this: will this have a shorthand? i.e. what will happen if i leave out the second part? ie. $var = $_GET['test'] ?? ; would that be the same as $var =

Re: [PHP-DEV] [RFC] Implicit isset() in Shorthand Ternary Operator

2014-09-17 Thread Kingsquare.nl - Robin Speekenbrink
2014-09-17 10:58 GMT+02:00 Sara Golemon p...@golemon.com: On Sep 16, 2014, at 13:46, Kingsquare.nl - Robin Speekenbrink ro...@kingsquare.nl wrote: As a userland point of view on this: will this have a shorthand? i.e. what will happen if i leave out the second part? ie. $var =

Re: [PHP-DEV] [RFC] Implicit isset() in Shorthand Ternary Operator

2014-09-17 Thread Matthew Fonda
Hi Andrea, This is great -- thanks to you and Nikita for the work here. Syntax wise, I would prefer a function-like syntax, e.g. coalesce($a, $b, 'c') or ifsetor() instead of $a ?? $b ?? 'c'. I find this more readable, and it avoids any possible confusion about precedence within the expressions.

Re: [PHP-DEV] [RFC] Implicit isset() in Shorthand Ternary Operator

2014-09-17 Thread Rowan Collins
Matthew Fonda wrote (on 17/09/2014): Hi Andrea, This is great -- thanks to you and Nikita for the work here. Syntax wise, I would prefer a function-like syntax, e.g. coalesce($a, $b, 'c') or ifsetor() instead of $a ?? $b ?? 'c'. I find this more readable, and it avoids any possible confusion

Re: [PHP-DEV] [RFC] Implicit isset() in Shorthand Ternary Operator

2014-09-16 Thread Andrea Faulds
On 10 Sep 2014, at 10:31, Pierre Joye pierre@gmail.com wrote: On Tue, Sep 9, 2014 at 12:58 AM, Adam Harvey ahar...@php.net wrote: On 8 September 2014 07:56, Christoph Becker cmbecke...@gmx.de wrote: +1 on ?? — there's precedent for it, and it means we don't have to explain why the

Re: [PHP-DEV] [RFC] Implicit isset() in Shorthand Ternary Operator

2014-09-16 Thread Adam Harvey
On 16 September 2014 11:34, Andrea Faulds a...@ajf.me wrote: By popular demand, I’ve changed the RFC to instead propose a ?? operator, after Nikita Popov generously donated a working ?? patch. In doing so, the RFC is renamed “Null Coalesce Operator”. Please read it:

Re: [PHP-DEV] [RFC] Implicit isset() in Shorthand Ternary Operator

2014-09-16 Thread Andrea Faulds
On 16 Sep 2014, at 19:38, Adam Harvey ahar...@php.net wrote: On 16 September 2014 11:34, Andrea Faulds a...@ajf.me wrote: By popular demand, I’ve changed the RFC to instead propose a ?? operator, after Nikita Popov generously donated a working ?? patch. In doing so, the RFC is renamed

Re: [PHP-DEV] [RFC] Implicit isset() in Shorthand Ternary Operator

2014-09-16 Thread Shashank Kumar
This will be a nice addition. Kudos to you! Is there an issue targeting next minor for this? (assuming there is one) ​

Re: [PHP-DEV] [RFC] Implicit isset() in Shorthand Ternary Operator

2014-09-16 Thread Andrea Faulds
On 16 Sep 2014, at 19:55, Shashank Kumar shashankkumar...@gmail.com wrote: This will be a nice addition. Kudos to you! Really, you should thank Nikita, not me. He wrote the patch. ^^ Is there an issue targeting next minor for this? (assuming there is one) Well, the patch is written for

Re: [PHP-DEV] [RFC] Implicit isset() in Shorthand Ternary Operator

2014-09-16 Thread Shashank Kumar
Really, you should thank Nikita, not me. He wrote the patch. ^^ ​He gets my bag of thanks for many things. Well, the patch is written for master. It could be back ported, but I don’t know how. Also, even if there is a 5.7, it sounds like it will consist purely of bug fixes and E_DEPRECATED

Re: [PHP-DEV] [RFC] Implicit isset() in Shorthand Ternary Operator

2014-09-16 Thread Thomas Bley
Andrea Faulds wrote on 16.09.2014 20:34: On 10 Sep 2014, at 10:31, Pierre Joye pierre@gmail.com wrote: On Tue, Sep 9, 2014 at 12:58 AM, Adam Harvey ahar...@php.net wrote: On 8 September 2014 07:56, Christoph Becker cmbecke...@gmx.de wrote: +1 on ?? — there's precedent for it, and it

Re: [PHP-DEV] [RFC] Implicit isset() in Shorthand Ternary Operator

2014-09-16 Thread Andrea Faulds
On 16 Sep 2014, at 20:28, Thomas Bley ma...@thomasbley.de wrote: What are the pros and cons of a new operator vs. a new function? For example, MySQL has a coalesce() function: http://dev.mysql.com/doc/refman/5.6/en/comparison-operators.html#function_coalesce A function is useless as it

Re: [PHP-DEV] [RFC] Implicit isset() in Shorthand Ternary Operator

2014-09-16 Thread Thomas Bley
Sorry, I mean to implement coalesce() as a token like isset() ? Regards, Thomas Andrea Faulds wrote on 16.09.2014 21:30: On 16 Sep 2014, at 20:28, Thomas Bley ma...@thomasbley.de wrote: What are the pros and cons of a new operator vs. a new function? For example, MySQL has a coalesce()

Re: [PHP-DEV] [RFC] Implicit isset() in Shorthand Ternary Operator

2014-09-16 Thread Christoph Becker
Andrea Faulds wrote: On 16 Sep 2014, at 19:38, Adam Harvey ahar...@php.net wrote: On 16 September 2014 11:34, Andrea Faulds a...@ajf.me wrote: By popular demand, I’ve changed the RFC to instead propose a ?? operator, after Nikita Popov generously donated a working ?? patch. In doing so,

Re: [PHP-DEV] [RFC] Implicit isset() in Shorthand Ternary Operator

2014-09-16 Thread Kingsquare.nl - Robin Speekenbrink
2014-09-16 22:00 GMT+02:00 Christoph Becker cmbecke...@gmx.de: Andrea Faulds wrote: On 16 Sep 2014, at 19:38, Adam Harvey ahar...@php.net wrote: On 16 September 2014 11:34, Andrea Faulds a...@ajf.me wrote: By popular demand, I’ve changed the RFC to instead propose a ?? operator, after

Re: [PHP-DEV] [RFC] Implicit isset() in Shorthand Ternary Operator

2014-09-16 Thread Andrea Faulds
On 16 Sep 2014, at 21:46, Kingsquare.nl - Robin Speekenbrink ro...@kingsquare.nl wrote: As a userland point of view on this: will this have a shorthand? No. i.e. what will happen if i leave out the second part? ie. $var = $_GET['test'] ?? ; would that be the same as $var =

Re: [PHP-DEV] [RFC] Implicit isset() in Shorthand Ternary Operator

2014-09-10 Thread Pierre Joye
On Tue, Sep 9, 2014 at 12:58 AM, Adam Harvey ahar...@php.net wrote: On 8 September 2014 07:56, Christoph Becker cmbecke...@gmx.de wrote: Am 08.09.2014 15:58, schrieb Andrea Faulds: We could add such an operator, perhaps with the ?? syntax. However, I don’t really like the idea. It’s too

Re: [PHP-DEV] [RFC] Implicit isset() in Shorthand Ternary Operator

2014-09-09 Thread rparker
From: Andrey Andreev Sent: ‎Monday‎, ‎September‎ ‎8‎, ‎2014 ‎5‎:‎16‎ ‎PM To: Andrea Faulds Cc: Adam Harvey, Christoph Becker, PHP internals On Tue, Sep 9, 2014 at 3:07 AM, Andrea Faulds a...@ajf.me wrote: On 8 Sep 2014, at 23:58, Adam Harvey ahar...@php.net wrote: +1 on ?? — there's

Re: [PHP-DEV] [RFC] Implicit isset() in Shorthand Ternary Operator

2014-09-09 Thread Rowan Collins
On 09/09/2014 18:08, rpar...@yamiko.org wrote: I agree and think we should go with a different operator as others suggested. If not ?? than we could use ?= like $foo ?= “default string”. That reads like an assignment, rather than an expression - particularly given PHP's large number of

Re: [PHP-DEV] [RFC] Implicit isset() in Shorthand Ternary Operator

2014-09-08 Thread Simon Schick
Hi, Andrea I feel more like Sherif Ramadan. Even so I've quite often been in the same situation, I don't think it's a good solution to change something like that, just for the shorthand-operator. I think, the notice is really valuable when accessing the value and doing something with it - like

Re: [PHP-DEV] [RFC] Implicit isset() in Shorthand Ternary Operator

2014-09-08 Thread Michael Wallner
On 07/09/14 14:25, Andrea Faulds wrote: On 7 Sep 2014, at 13:22, Sherif Ramadan theanomaly...@gmail.com wrote: I've played around with this branch for a bit and seems reasonable, passes the tests, and doesn't seem to have any serious issues/memories leaks AFAICT. There’s actually a

Re: [PHP-DEV] [RFC] Implicit isset() in Shorthand Ternary Operator

2014-09-08 Thread Sherif Ramadan
On Mon, Sep 8, 2014 at 4:06 AM, Michael Wallner m...@php.net wrote: On 07/09/14 14:25, Andrea Faulds wrote: There’s actually a quite serious issue just now, which is that it evaluates the first operand twice if it’s not empty. This is because $a ?: $b is expanded to empty($a) ? $b : $a,

Re: [PHP-DEV] [RFC] Implicit isset() in Shorthand Ternary Operator

2014-09-08 Thread Shashank Kumar
Hi Andrea Rather than giving a new meaning to an old operator why not have a different operator for this? .NET has a 'null coalescing' operator for the same purpose which works out quite well in the given situation and is non-ambiguous as well.

Re: [PHP-DEV] [RFC] Implicit isset() in Shorthand Ternary Operator

2014-09-08 Thread Andrea Faulds
On 8 Sep 2014, at 09:06, Michael Wallner m...@php.net wrote: On 07/09/14 14:25, Andrea Faulds wrote: On 7 Sep 2014, at 13:22, Sherif Ramadan theanomaly...@gmail.com wrote: I've played around with this branch for a bit and seems reasonable, passes the tests, and doesn't seem to have any

Re: [PHP-DEV] [RFC] Implicit isset() in Shorthand Ternary Operator

2014-09-08 Thread Christoph Becker
Am 08.09.2014 15:58, schrieb Andrea Faulds: On 8 Sep 2014, at 13:04, Shashank Kumar shashankkumar...@gmail.com wrote: Rather than giving a new meaning to an old operator why not have a different operator for this? .NET has a 'null coalescing' operator for the same purpose which works out

Re: [PHP-DEV] [RFC] Implicit isset() in Shorthand Ternary Operator

2014-09-08 Thread Adam Harvey
On 8 September 2014 07:56, Christoph Becker cmbecke...@gmx.de wrote: Am 08.09.2014 15:58, schrieb Andrea Faulds: We could add such an operator, perhaps with the ?? syntax. However, I don’t really like the idea. It’s too similar to ?: so I don’t think it’d be accepted, and even if it was, I’m

Re: [PHP-DEV] [RFC] Implicit isset() in Shorthand Ternary Operator

2014-09-08 Thread Andrea Faulds
On 8 Sep 2014, at 23:58, Adam Harvey ahar...@php.net wrote: +1 on ?? — there's precedent for it, and it means we don't have to explain why the shorthand form of an operator behaves differently to the long form, which is just going to confuse users. FWIW, it already behaves differently:

Re: [PHP-DEV] [RFC] Implicit isset() in Shorthand Ternary Operator

2014-09-08 Thread Adam Harvey
On 8 September 2014 17:07, Andrea Faulds a...@ajf.me wrote: On 8 Sep 2014, at 23:58, Adam Harvey ahar...@php.net wrote: +1 on ?? — there's precedent for it, and it means we don't have to explain why the shorthand form of an operator behaves differently to the long form, which is just going

Re: [PHP-DEV] [RFC] Implicit isset() in Shorthand Ternary Operator

2014-09-08 Thread Andrey Andreev
On Tue, Sep 9, 2014 at 3:07 AM, Andrea Faulds a...@ajf.me wrote: On 8 Sep 2014, at 23:58, Adam Harvey ahar...@php.net wrote: +1 on ?? — there's precedent for it, and it means we don't have to explain why the shorthand form of an operator behaves differently to the long form, which is just

Re: [PHP-DEV] [RFC] Implicit isset() in Shorthand Ternary Operator

2014-09-07 Thread Pierre Joye
Hi Andrea, On Sep 6, 2014 2:03 AM, Andrea Faulds a...@ajf.me wrote: Good evening, I’ve written an RFC and working patch which attempt to add this feature which has been often requested: https://wiki.php.net/rfc/isset_ternary I did not look at the patch yet but I like it from a feature point

Re: [PHP-DEV] [RFC] Implicit isset() in Shorthand Ternary Operator

2014-09-07 Thread Sherif Ramadan
I've played around with this branch for a bit and seems reasonable, passes the tests, and doesn't seem to have any serious issues/memories leaks AFAICT. I can't stress enough, however, how important it is for us to avoid inconsistencies in behavior between various forms of syntax. This is often

Re: [PHP-DEV] [RFC] Implicit isset() in Shorthand Ternary Operator

2014-09-07 Thread Andrea Faulds
On 7 Sep 2014, at 13:22, Sherif Ramadan theanomaly...@gmail.com wrote: I've played around with this branch for a bit and seems reasonable, passes the tests, and doesn't seem to have any serious issues/memories leaks AFAICT. There’s actually a quite serious issue just now, which is that it

[PHP-DEV] [RFC] Implicit isset() in Shorthand Ternary Operator

2014-09-05 Thread Andrea Faulds
Good evening, I’ve written an RFC and working patch which attempt to add this feature which has been often requested: https://wiki.php.net/rfc/isset_ternary Thanks! -- Andrea Faulds http://ajf.me/ -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: