4 ms·
PHP got the nullsafe operator in version 8.0, released in 2020. That's two and a half decades of language improvement before this common idiom: $foo = getFoo
by dotancohen 4y ago
PHP got the nullsafe operator in version 8.0, released in 2020. That's two and a half decades of language improvement before this common idiom:
$foo = getFoo();
if ( !$foo ) {
return null;
}
$foo = $foo->getBar();
if ( !$foo ) {
return null;
}
return $foo->getBaz();
...could be replaced with this:
return getFoo()?->getBar()?->getBaz();
And that was with a strong committee actually interested in improving the language.
> we could reasonably define better abstractions to avoid the need
> to verbosely repeat each pattern each time by replacing them with
> shorter, well-defined qualifiers.
The side-effects of those qualifiers are untested and unknown, and the current long legalese serves the people that it is meant to serve. Some might even call the ambiguity and ability to argue semantics a feature.
- feanaro 4y ago> The side-effects of those qualifiers are untested and unknown, If you define the qualifiers to be a literal shorthand for the current status quo litany, what side-effects do you envision, other than better readability? > and the current long legalese serves the people that it is meant to serve. Does it, though? With the long-winded expensive processes favouring those with capital and punishing those with none into unjust settlements for fear of debilitating costs? With practically requiring expensive lawyers in order to have any hope of navigating the byzantine mazes of modern law?