Hey Dan, On 9 November 2015 at 23:24, Dan Ackroyd <dan...@basereality.com> wrote:
> Hi Reeze, > > On 9 November 2015 at 13:35, reeze <re...@php.net> 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 possible to get the affect that you want without adding anything to the core by > doing this: > > $defaults = ['default', 'default']; > $input = [1]; > > list($a, $b) = array_replace($defaults, $input); > > I'd find that way easier to understand and explain to junior devs, > I saw the contrast way, it is more complex ;-). This seems like a trick. Many feature could also be remove, such as I refered in RFC: Null coalesce "??" and Ternary Operator "?:" And the trick is trick. If you want to unpack nested array. list($a, list(list($b))) = $array Then you might need a new trick to do that. You know we have default for function declaration: function func($a='default') {}; and almost all language have the feature, it is easier to understand from my perspective. > compared to having more functionality added to the 'list' magicness. > > cheers > Dan > -- Reeze Xia http://reeze.cn