Re: [PHP-DEV] [RFC][DISCUSSION] Allow default value in list() syntax

2017-08-14 Thread Marco Pivetta
> 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 Mo

Re: [PHP-DEV] [RFC][DISCUSSION] Allow default value in list() syntax

2017-08-14 Thread Björn Larsson
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 tempora

Re: [PHP-DEV] [RFC][DISCUSSION] Allow default value in list() syntax

2017-08-11 Thread 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

Re: [PHP-DEV] [RFC][DISCUSSION] Allow default value in list() syntax

2017-08-11 Thread Andreas Treichel
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

Re: [PHP-DEV] [RFC][DISCUSSION] Allow default value in list() syntax

2017-08-11 Thread Devnuhl Unnamed
When you understand something, it often can be hard to understand why others wouldn't. I don't see why people struggle with it either, but I do see it happen quite a lot. I would still think that if you are going to deconstruct something in a structured way, you should validate your data is correc

Re: [PHP-DEV] [RFC][DISCUSSION] Allow default value in list() syntax

2017-08-11 Thread Tony Marston
"Andreas Hennings" wrote in message news:CAH0Uv3HQK5wjcd_-9GynMw34H78ZTv09q9bc=yZ10JBbeT=v...@mail.gmail.com... On Fri, Aug 11, 2017 at 12:01 AM, Devnuhl Unnamed wrote: Would isset($suffix) not suffice here? You mean like so? list($prefix, $suffix) = explode(':', 'string_without_suffix');

Re: [PHP-DEV] [RFC][DISCUSSION] Allow default value in list() syntax

2017-08-10 Thread Andreas Hennings
On Fri, Aug 11, 2017 at 12:01 AM, Devnuhl Unnamed wrote: > Would isset($suffix) not suffice here? You mean like so? list($prefix, $suffix) = explode(':', 'string_without_suffix'); if (!isset($suffix)) { .. } The isset() is too late here, because the list() will already cause an error. > Oth

Re: [PHP-DEV] [RFC][DISCUSSION] Allow default value in list() syntax

2017-08-10 Thread Devnuhl Unnamed
Would isset($suffix) not suffice here? There are several things I've thought of that would be other alternatives to changing this language construct, but as I don't have my laptop with me, some of the testing to confirm behavior will have to wait. Other concerns fall around list() already being a

Re: [PHP-DEV] [RFC][DISCUSSION] Allow default value in list() syntax

2017-08-10 Thread Sara Golemon
On Thu, Aug 10, 2017 at 5:21 PM, Andreas Hennings wrote: > 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 regularly want this kind of feature when unpacking a string with ex

Re: [PHP-DEV] [RFC][DISCUSSION] Allow default value in list() syntax

2017-08-10 Thread Andreas Hennings
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 wrote: > Hello list, > > I found this RFC, describing a feature I wanted for a long time: > https://wiki.p

Re: [PHP-DEV] [RFC][DISCUSSION] Allow default value in list() syntax

2017-08-10 Thread Andreas Hennings
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.)

Re: [PHP-DEV] [RFC][DISCUSSION] Allow default value in list() syntax

2016-01-21 Thread randomly there
On 1/21/2016 8:49 AM, reeze wrote: > Bump this to continue discussion of this RFC ( > https://wiki.php.net/rfc/list_default_value). > > In case some of you didn't follow it before. This RFC propose to allow set > default value in list() assignment: > > list($a = 'default value') = $arr; > tl;dr -

Re: [PHP-DEV] [RFC][DISCUSSION] Allow default value in list() syntax

2016-01-21 Thread reeze
Bump this to continue discussion of this RFC ( https://wiki.php.net/rfc/list_default_value). In case some of you didn't follow it before. This RFC propose to allow set default value in list() assignment: list($a = 'default value') = $arr; On 10 November 2015 at 11:14, reeze wrote: > Hey Dan,

Re: [PHP-DEV] [RFC][DISCUSSION] Allow default value in list() syntax

2015-11-09 Thread reeze
Hey Dan, On 9 November 2015 at 23:24, Dan Ackroyd wrote: > Hi Reeze, > > On 9 November 2015 at 13:35, reeze wrote: > > Hi internals! > > > > I'd like to open a discussion on the RFC to allow set default values for > > list() assignment: https://wiki.php.net/rfc/list_default_value. > > > > What

Re: [PHP-DEV] [RFC][DISCUSSION] Allow default value in list() syntax

2015-11-09 Thread Dan Ackroyd
Hi Reeze, On 9 November 2015 at 13:35, reeze wrote: > Hi internals! > > I'd like to open a discussion on the RFC to allow set default values for > list() assignment: https://wiki.php.net/rfc/list_default_value. > > What is your idea? I find the list construct to be quite magic already. Isn't it

[PHP-DEV] [RFC][DISCUSSION] Allow default value in list() syntax

2015-11-09 Thread reeze
Hi internals! I'd like to open a discussion on the RFC to allow set default values for list() assignment: https://wiki.php.net/rfc/list_default_value. What is your idea? Thanks. -- Reeze Xia http://reeze.cn