On Sun, Apr 23, 2023, at 6:01 PM, Máté Kocsis wrote: > What about argument unpacking? >> I don't know if we can combine this with ":" syntax or only with "=>". > > > For now, argument unpacking (property unpacking?) is not possible. But it > is definitely something that could be added in the future.
Not currently written but could be, or there's some reason why that is particularly hard? > Tim wrote: > > I'd rather see only the fat-arrow being allowed. Unless I'm missing >> something, braces with colon is not used anywhere else, whereas braces + >> '=>' is known from match() and '=>' more generally is already used with >> array literals [1]. Having two similar syntaxes for the same thing is >> not great when both are commonly needed is not great. They need to be >> documented and learned by developers. > > > I can only repeat what Rowan answered, since I agree with it completely: > > I think it makes sense to have an unquoted form here, because the common >> case is that they are names which analysers can match statically to >> particular properties, not strings which will be analysed at runtime. There >> are plenty of places in the language where dynamic names are allowed, but >> we don't just use strings for the static case > > > However, I'm not completely sold on making "clone with" look like a > function call (return clone $this with (a: 1);), but > at least I like it more than using an array-like style (return clone > $this > with [a: 1];). My intention with > using curly brackets (return clone $this with {a: 1};) is to highlight > the > fact that it is a map > of key-value pairs, similarly how the JSON standard does so. Not to > mention > that "clone with" serves a very > similar purpose to object initializers, and the different languages I > know > to have this feature use > a similar syntax (Java: http://wiki.c2.com/?DoubleBraceInitialization, > C#: > https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/object-and-collection-initializers#object-initializers > ). > > Regards, > Máté True, but PHP 8.0 sort of added something close to object initializers with the combination of constructor promotion and named arguments. It's not exactly the same thing, but it's the effective equivalent in PHP today. So if you want to model on object initializers, named args would be the closest PHP equivalent. --Larry Garfield -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php