Re: Unifying logical operators

From: Date: Tue, 10 Jul 2018 19:21:18 +0000
Subject: Re: Unifying logical operators
References: 1 2 3 4 5 6 7 8  Groups: php.internals 
Request: Send a blank email to internals+get-102732@lists.php.net to get a copy of this message
On 10/07/2018 20:11, Kalle Sommer Nielsen wrote:
Den tir. 10. jul. 2018 kl. 21.08 skrev David Rodrigues <david.proweb@gmail.com>:
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().
I in fact find that more unreadable as you first got to dig through the error handling before you actually get to the logic that triggered it.
A more readable syntax, if we were designing from scratch, might be to look at SmallTalk, where ifTrue and ifFalse are methods on the boolean class, so can appear post-fix after any boolean, giving you something like: $connected ifFalse: die(); Regards, -- Rowan Collins [IMSoP]

« previous php.internals (#102732) next »