> that doesn't clutter the language.

It actually does: now we have an expression-alike node that is lazy and
only evaluated when there's no default value. That's a lot of added
semantics for such an edge case feature.

Marco Pivetta

http://twitter.com/Ocramius

http://ocramius.github.com/

On Mon, Aug 14, 2017 at 11:35 AM, Björn Larsson <bjorn.x.lars...@telia.com>
wrote:

> Den 2017-08-12 kl. 02:37, skrev Andreas Hennings:
>
> This is true, I remember having done it in the past.
>>
>> I still think it would be nice and feel natural to have the default
>> values directly built into the list construct.
>>
>> It would be a bit faster, because it does not have to allocate a new
>> temporary array.
>>
>> Whether this difference matters depends on the case.
>> In my own philosophy, every code that I write to be reusable, could at
>> some point be used in a situation where it is repeated a lot, and thus
>> has a performance impact. So for my taste, it does matter.
>>
>> This said, I understand it not having the greatest priority.
>>
>>
>>
>> On Fri, Aug 11, 2017 at 7:46 PM, Andreas Treichel <gmb...@gmail.com>
>> wrote:
>>
>>> You can merge the result with default values like this:
>>>
>>> [$foo, $bar, $foobar] = explode(':', 'foo:bar') + [23, 42, 1337];
>>> var_dump($foo, $bar, $foobar);
>>>
>>>
>>>
>>> --
>>> PHP Internals - PHP Runtime Development Mailing List
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>> One could argue that:
> [$foo, $bar, $foobar = 1337] = explode(':', 'foo:bar');
>
> is more readable. I find it a small but nice addition
> that doesn't clutter the language.
>
> r//Björn
>
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Reply via email to