Hi Pavel
> https://wiki.php.net/rfc/guard_statement
> <https://wiki.php.net/rfc/unbundle_xmlprc>
First of all, thanks for your proposal!
I'm a bit skeptical. guard is mostly useful in Swift because it's a
strictly typed language.
let x = foo() // type Int?
if x == nil { return }
// x is still Int?
Guard is kind of an inverted if statement for them.
guard let x = foo() { return }
// x is Int
In PHP we don't have this problem as there are no (or few) compile
time type checks.
guard (null !== $x = foo()) { return; }
// No benefit over
if (null !== $x = foo()) { return; }
The only benefit is that the block is forced to be terminating but
that's not worth it IMO.
Ilija
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php