Re: [PHP-DEV] [RFC] Allow specifying keys in list()

2016-01-21 Thread Stanislav Malyshev
Hi! > Here's an RFC that would extend the syntax of list() to be more useful > with associative arrays: > > https://wiki.php.net/rfc/list_keys > > Please read it and tell me your thoughts. After reading the RFC, it looks like a great idea. I wouldn't exactly encourage this for replacement of na

Re: AW: [PHP-DEV] [RFC] Allow specifying keys in list()

2016-01-20 Thread Thomas Bley
since I think this is rather out of scope. > > -Ursprüngliche Nachricht- >> Von: Pierre Joye [mailto:pierre@gmail.com] >> Gesendet: Montag, 18. Januar 2016 05:54 >> An: Andrea Faulds >> Cc: PHP internals >> Betreff: Re: [PHP-DEV] [RFC] Allow specif

AW: [PHP-DEV] [RFC] Allow specifying keys in list()

2016-01-20 Thread Robert Stoll
Hi Andrea I am writing you in private since I think this is rather out of scope. -Ursprüngliche Nachricht- > Von: Pierre Joye [mailto:pierre@gmail.com] > Gesendet: Montag, 18. Januar 2016 05:54 > An: Andrea Faulds > Cc: PHP internals > Betreff: Re: [PHP-DEV] [RFC] A

Re: [PHP-DEV] [RFC] Allow specifying keys in list()

2016-01-19 Thread Rowan Collins
Lester Caine wrote on 19/01/2016 11:49: If we ever add object literals, then >we could do object destructuring with a symmetrical syntax. Andrea, please bare with me as I'm trying to work out just what some of those long words actually mean. I think what Andrea's getting at is being able to do

Re: [PHP-DEV] [RFC] Allow specifying keys in list()

2016-01-19 Thread Leigh
On 19 January 2016 at 02:20, Andrea Faulds wrote: > After considering how to implement this at the opcode level, I've decided > again that it's not worth it. Mixing keyed and unkeyed elements is not only > an implementation nuisance (it's not necessarily hard, but it makes things > more complicate

Re: [PHP-DEV] [RFC] Allow specifying keys in list()

2016-01-19 Thread Lester Caine
On 19/01/16 01:35, Andrea Faulds wrote: >> $point = new Point(21, 42); >> list('x' => $x, 'y' => $y) = $point; > > You can't do `$x = $point['x'];`, so `list("x" => $x) = $point;` won't > work either. If you want list() support, implement ArrayAccess. > > We could potentially add some extension t

Re: [PHP-DEV] [RFC] Allow specifying keys in list()

2016-01-18 Thread Andrea Faulds
Hi again, Andrea Faulds wrote: How feasible would it be to add an exception to mixed keys? I'm thinking list(7 => $a, $b, $c, $d) to specify an initial offset, similar to how you can define an array as [7 => 0, 1, 2, 3]. This obviously goes hand in hand with my desire for variable keys :) Oh,

Re: [PHP-DEV] [RFC] Allow specifying keys in list()

2016-01-18 Thread Andrea Faulds
Hi Thomas, Thomas Bley wrote: What about using objects with list()? class Point { public function __construct($x, $y) { $this->x = $x; $this->y = $y; } } $point = new Point(21, 42); list('x' => $x, 'y' => $y) = $point; You can't do `$x = $point['x'];`, so `list("x" => $x) = $point;` wo

Re: [PHP-DEV] [RFC] Allow specifying keys in list()

2016-01-18 Thread Andrea Faulds
Hi Leigh, Leigh wrote: The uses for this extended syntax go beyond simply populating object properties, and shoehorning it into extract would pretty much limit it to this use-case. In fact I don't think extract() even works on object properties. list() works with any "variable" (in the isse

Re: [PHP-DEV] [RFC] Allow specifying keys in list()

2016-01-18 Thread S.A.N
> How feasible would it be to add an exception to mixed keys? I'm thinking > list(7 => $a, $b, $c, $d) to specify an initial offset, similar to how you > can define an array as [7 => 0, 1, 2, 3]. This obviously goes hand in hand > with my desire for variable keys :) I would like it to be like, des

Re: [PHP-DEV] [RFC] Allow specifying keys in list()

2016-01-18 Thread Thomas Bley
What about using objects with list()? class Point { public function __construct($x, $y) { $this->x = $x; $this->y = $y; } } $point = new Point(21, 42); list('x' => $x, 'y' => $y) = $point; Regards Thomas Andrea Faulds wrote on 17.01.2016 03:32: > Hi everyone, > > Here's an RFC that would

Re: [PHP-DEV] [RFC] Allow specifying keys in list()

2016-01-18 Thread Leigh
On 18 January 2016 at 12:35, Lester Caine wrote: > > Hi! > > > > I found the idea convincing from the first read, but maybe it's just my > > mind's assumptions about list() that I dislike the resulting syntax, > > yet, it seems to be the logical choice. > > > > So, maybe I'm just trying to say, t

Re: [PHP-DEV] [RFC] Allow specifying keys in list()

2016-01-18 Thread Rowan Collins
Lester Caine wrote on 18/01/2016 12:35: As someone still using 'extract' in legacy code, I can sort of see the logistics of this, but why not just extend 'extract' to use the current object rather than the symbol table. It already has handling for duplicate keys and to prefix the 'array' name to

Re: [PHP-DEV] [RFC] Allow specifying keys in list()

2016-01-18 Thread Lester Caine
On 18/01/16 07:19, Michael Wallner wrote: >> Here's an RFC that would extend the syntax of list() to be more useful >> > with associative arrays: >> > >> > https://wiki.php.net/rfc/list_keys >> > >> > Please read it and tell me your thoughts. > Hi! > > I found the idea convincing from the first

Re: [PHP-DEV] [RFC] Allow specifying keys in list()

2016-01-17 Thread Michael Wallner
On 17/01/16 03:32, Andrea Faulds wrote: > Hi everyone, > > Here's an RFC that would extend the syntax of list() to be more useful > with associative arrays: > > https://wiki.php.net/rfc/list_keys > > Please read it and tell me your thoughts. Hi! I found the idea convincing from the first read,

Re: [PHP-DEV] [RFC] Allow specifying keys in list()

2016-01-17 Thread Pierre Joye
hi Andrea, I very much like this proposal. Good work as usual! The only part where I think we should not rely on list is the future scope. I can see the logic that leads to use list for named arguments. However I really think it is a very different topic and having to use list to define arguments

Re: [PHP-DEV] [RFC] Allow specifying keys in list()

2016-01-17 Thread Andrea Faulds
Hi Bishop, Bishop Bettini wrote: On Sat, Jan 16, 2016 at 9:32 PM, Andrea Faulds wrote: Hi everyone, Here's an RFC that would extend the syntax of list() to be more useful with associative arrays: https://wiki.php.net/rfc/list_keys Please read it and tell me your thoughts. Nice, Andrea,

Re: [PHP-DEV] [RFC] Allow specifying keys in list()

2016-01-17 Thread Bishop Bettini
On Sat, Jan 16, 2016 at 9:32 PM, Andrea Faulds wrote: > Hi everyone, > > Here's an RFC that would extend the syntax of list() to be more useful > with associative arrays: > > https://wiki.php.net/rfc/list_keys > > Please read it and tell me your thoughts. > Nice, Andrea, thanks! Destructuring is

[PHP-DEV] [RFC] Allow specifying keys in list()

2016-01-16 Thread Andrea Faulds
Hi everyone, Here's an RFC that would extend the syntax of list() to be more useful with associative arrays: https://wiki.php.net/rfc/list_keys Please read it and tell me your thoughts. Thanks! -- Andrea Faulds https://ajf.me/ -- PHP Internals - PHP Runtime Development Mailing List To unsub