Re: [RFC] Default expression

From: Date: Tue, 27 Aug 2024 11:56:40 +0000
Subject: Re: [RFC] Default expression
References: 1  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
On Sat, 24 Aug 2024, Bilge 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.

I liked this up to the point where I saw:

$f = fn ($v = 1, $default = 2) => $v + $default;
var_dump($f(default: default + 1)); // int(4)

Using 'default' as a place holder for (not) passing an argument seems 
useful. I am however much uncertain about using composition with the 
keyword in expressions.

I also think that implementation would probably be significantly less 
complex as it was only used for placeholders. It's likely something that 
can be handled in the parser.

Having an opcode for it, that does internal reflection, is what I'm 
unsure about.

cheers,
Derick


Thread (101 messages)

« previous php.internals (#125314) next »