I don't have a strong opinion about the nested list() construct which
is also part of the RFC.
I never had a situation where I wanted this.

On Thu, Aug 10, 2017 at 11:21 PM, Andreas Hennings <andr...@dqxtech.net> wrote:
> Hello list,
>
> I found this RFC, describing a feature I wanted for a long time:
> https://wiki.php.net/rfc/list_default_value
> https://marc.info/?l=php-internals&m=144707619509724
>
> (I don't know how to correctly reply to old emails that are not in my
> inbox, sorry for that. I don't like mailing lists.)
>
> I regularly want this kind of feature when unpacking a string with explode():
>
> list($prefix, $suffix = NULL) = explode(':', $string);
> if (NULL !== $suffix) {
>   ...
> }
>
> This is for situations where a string is coming from somewhere, we
> hope it has the format "aaa:bbb", but we cannot be sure.
>
> Sometimes I use a workaround like this:
>
> list($prefix, $suffix) = explode(':', $string . ':');
> if ('' !== $suffix) {
>   ...
> }
> Which works, but means a new string will be allocated in memory.
>
> I find the list() with default values to be a decent and
> understandable language feature.
>
> -- Andreas

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to