Re: [PHP-DEV] Unifying logical operators

2018-07-11 Thread Rowan Collins
On 11 July 2018 at 03:20, Ryan wrote: > > PHP 7 code should never be blindly upgraded to PHP 8 (which is what this > would target for actual changes, not just deprecation/notices). This would > have to be clearly stated in the upgrade guide. > There's a big difference between "not blindly upda

Re: [PHP-DEV] Unifying logical operators

2018-07-11 Thread Andrey Andreev
Hi, On Wed, Jul 11, 2018 at 5:20 AM, Ryan wrote: > On Tue, Jul 10, 2018 at 2:58 PM, Andrey Andreev wrote: > >> isset($foo) OR $foo = 'bar'; (and similar variations using empty() >> and/or &&) is another pattern I use often to set fallback values for >> empty or missing inputs. >> >> An eventual

Re: [PHP-DEV] Unifying logical operators

2018-07-10 Thread Ryan
On Tue, Jul 10, 2018 at 10:58 PM, Alice Wonder wrote: > Using github may not be the most reliable method. > > Look at what is most popularly used in composer dependencies. Absolutely - but it's the first one that came to mind when thinking of "how to get popular repositories really quick". I

Re: [PHP-DEV] Unifying logical operators

2018-07-10 Thread Walter Parker
On Tue, Jul 10, 2018 at 7:58 PM, Alice Wonder wrote: > On 07/10/2018 07:20 PM, Ryan wrote: > >> On Tue, Jul 10, 2018 at 2:26 AM, Walter Parker wrote: >> >> >>> That is a matter of style, as I find $a = func() or die more clear that >>> the version that uses || >>> >>> Not chaining stuff together

Re: [PHP-DEV] Unifying logical operators

2018-07-10 Thread Alice Wonder
On 07/10/2018 07:20 PM, Ryan wrote: On Tue, Jul 10, 2018 at 2:26 AM, Walter Parker wrote: That is a matter of style, as I find $a = func() or die more clear that the version that uses || Not chaining stuff together is a third style. This feels like a Python PEP request. By that I mean that

Re: [PHP-DEV] Unifying logical operators

2018-07-10 Thread Ryan
On Tue, Jul 10, 2018 at 2:26 AM, Walter Parker wrote: > > That is a matter of style, as I find $a = func() or die more clear that > the version that uses || > > Not chaining stuff together is a third style. > > This feels like a Python PEP request. By that I mean that Python wants to > have only

Re: [PHP-DEV] Unifying logical operators

2018-07-10 Thread Rowan Collins
On 10/07/2018 20:38, Michael Morris wrote: While having these behave they do is unfortunate, it is hardly the only one of PHP's quirks. Ever looked at the ramifications of loose typing with comparison?http://phpsadness.com/sad/52 Eugh, I hate that site, and I hate that it's so widely linked a

Re: [PHP-DEV] Unifying logical operators

2018-07-10 Thread Michael Morris
On Mon, Jul 9, 2018 at 10:03 PM Ryan wrote: > Hello all! Longtime PHP user, first-time contributor to internals (sorry > if I screw anything up)! > > I'd like to propose either the deprecation (7.next - likely 7.4 at this > point) and removal (8.0) of the T_LOGICAL_OR (or), T_LOGICAL_AND (and),

Re: [PHP-DEV] Unifying logical operators

2018-07-10 Thread Rowan Collins
On 10/07/2018 20:11, Kalle Sommer Nielsen wrote: Den tir. 10. jul. 2018 kl. 21.08 skrev David Rodrigues : I think that "or" could be removed if PHP could supports inline conditionals like: die() if !$connected; throw Exception() if fail(); $x = $y if (z() && w()); Or "when": die() when !$conn

Re: [PHP-DEV] Unifying logical operators

2018-07-10 Thread Kalle Sommer Nielsen
Den tir. 10. jul. 2018 kl. 21.08 skrev David Rodrigues : > > I think that "or" could be removed if PHP could supports inline conditionals > like: > > die() if !$connected; > throw Exception() if fail(); > $x = $y if (z() && w()); > > Or "when": die() when !$connected; > > It seems more clear than

Re: [PHP-DEV] Unifying logical operators

2018-07-10 Thread David Rodrigues
I think that "or" could be removed if PHP could supports inline conditionals like: die() if !$connected; throw Exception() if fail(); $x = $y if (z() && w()); Or "when": die() when !$connected; It seems more clear than $connected or die(). Em ter, 10 de jul de 2018 às 15:59, Andrey Andreev esc

Re: [PHP-DEV] Unifying logical operators

2018-07-10 Thread Andrey Andreev
Hi, On Tue, Jul 10, 2018 at 9:37 PM, Kalle Sommer Nielsen wrote: > Den tir. 10. jul. 2018 kl. 20.22 skrev Larry Garfield > : >> "do() or die()" code is/was very common in example code, tutorials, and other >> intro material because it means you don't need to think about error handling. > > I per

Re: [PHP-DEV] Unifying logical operators

2018-07-10 Thread Kalle Sommer Nielsen
Den tir. 10. jul. 2018 kl. 20.22 skrev Larry Garfield : > "do() or die()" code is/was very common in example code, tutorials, and other > intro material because it means you don't need to think about error handling. I personally wanted to extend this syntax but I never got around to it to support:

Re: [PHP-DEV] Unifying logical operators

2018-07-10 Thread Larry Garfield
On Tuesday, July 10, 2018 6:09:22 AM CDT Christoph M. Becker wrote: > On 10.07.2018 at 11:01, Rowan Collins wrote: > > While I've not seen it used much in PHP code, the "do this or die" idiom > > is > > common in Perl (which also has post-fix "if" and "unless" modifiers, so > > those are a differen

Re: [PHP-DEV] Unifying logical operators

2018-07-10 Thread Christoph M. Becker
On 10.07.2018 at 13:41, Rowan Collins wrote: > On 10 July 2018 at 12:09, Christoph M. Becker wrote: > >> “xor” is equivalent to ^ (sans the precedence). > > No, that's a *bitwise* XOR, which is a completely different operation: > > var_dump(1 xor 2); // bool(false) > var_dump(1 ^ 2); // int(3)

Re: [PHP-DEV] Unifying logical operators

2018-07-10 Thread Rowan Collins
On 10 July 2018 at 12:09, Christoph M. Becker wrote: > > “xor” is equivalent to ^ (sans the precedence). > No, that's a *bitwise* XOR, which is a completely different operation: var_dump(1 xor 2); // bool(false) var_dump(1 ^ 2); // int(3) A consistent logical XOR with the same precedence as |

Re: [PHP-DEV] Unifying logical operators

2018-07-10 Thread Christoph M. Becker
On 10.07.2018 at 11:01, Rowan Collins wrote: > While I've not seen it used much in PHP code, the "do this or die" idiom is > common in Perl (which also has post-fix "if" and "unless" modifiers, so > those are a different feature again). It seems to me the “do this or die” idiom at least has been

Re: [PHP-DEV] Unifying logical operators

2018-07-10 Thread Rowan Collins
On 10 July 2018 at 04:02, Ryan wrote: > > defined("SOME_CONSTANT") or die("SOME_CONSTANT was not defined"); > > However, this behaviour has nothing to do with the difference of precedence > - rather this is due to short circuiting. > As your own next example demonstrates, it does rely on the di

Re: [PHP-DEV] Unifying logical operators

2018-07-09 Thread Walter Parker
On Mon, Jul 9, 2018 at 9:03 PM Ryan wrote: > Hello all! Longtime PHP user, first-time contributor to internals (sorry > if I screw anything up)! > > I'd like to propose either the deprecation (7.next - likely 7.4 at this > point) and removal (8.0) of the T_LOGICAL_OR (or), T_LOGICAL_AND (and), a

[PHP-DEV] Unifying logical operators

2018-07-09 Thread Ryan
Hello all! Longtime PHP user, first-time contributor to internals (sorry if I screw anything up)! I'd like to propose either the deprecation (7.next - likely 7.4 at this point) and removal (8.0) of the T_LOGICAL_OR (or), T_LOGICAL_AND (and), and T_LOGICAL_XOR (xor) tokens, or aliasing them to ||,