Re: [RFC] Default expression

From: Date: Mon, 26 Aug 2024 14:20:33 +0000
Subject: Re: [RFC] Default expression
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-125272@lists.php.net to get a copy of this message
> On 24 Aug 2024, at 23:49, Bilge <bilge@scriptfusion.com> wrote: > > Hi gang, > > New RFC just dropped: > https://wiki.php.net/rfc/default_expression. I think some of you > might enjoy this one. Hit me with any feedback. > > This one already comes complete with working implementation that I've been cooking for a > little while. Considering I don't know C or PHP internals, one might think implementing this > feature would be prohibitively difficult, but considering the amount of help and guidance I received > from Ilija, Bob and others, it would be truer to say it would have been more difficult to fail! Huge > thanks to them. > > Cheers, > Bilge > Hi, I noticed someone talking about the various ways the default keyword could be used in an expression including in match() and looking in the RFC examples I see it is listed, so I think it's useful to clarify here. I haven't followed the entire thread in depth so I apologise if this was already answered, but I haven't noticed it being mentioned/clarified yet. Can you clarify in the following, is the arm comparing against match's default or the parameter's default? Or to put it another way, in the second call, If $arg is 2, will the match error out due to an unmatched subject, or will it pass 1 to F? function F(int $foo = 1) {} F(match(default) { default => default }); F(match($arg) { 'a' => 0, default => default }); Cheers Stephen

« previous php.internals (#125272) next »