Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:90712 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 73928 invoked from network); 19 Jan 2016 11:49:46 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Jan 2016 11:49:46 -0000 Authentication-Results: pb1.pair.com header.from=lester@lsces.co.uk; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=lester@lsces.co.uk; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain lsces.co.uk from 217.147.176.204 cause and error) X-PHP-List-Original-Sender: lester@lsces.co.uk X-Host-Fingerprint: 217.147.176.204 mail4.serversure.net Linux 2.6 Received: from [217.147.176.204] ([217.147.176.204:40319] helo=mail4.serversure.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 5A/51-61693-8D22E965 for ; Tue, 19 Jan 2016 06:49:45 -0500 Received: (qmail 28423 invoked by uid 89); 19 Jan 2016 11:49:42 -0000 Received: by simscan 1.3.1 ppid: 28417, pid: 28420, t: 0.0871s scanners: attach: 1.3.1 clamav: 0.96/m:52/d:10677 Received: from unknown (HELO ?10.0.0.7?) (lester@rainbowdigitalmedia.org.uk@81.138.11.136) by mail4.serversure.net with ESMTPA; 19 Jan 2016 11:49:41 -0000 To: internals@lists.php.net References: <20160118131911.DA1832607EC@dd15934.kasserver.com> <12.0F.20254.2D29D965@pb1.pair.com> Message-ID: <569E22D5.4040900@lsces.co.uk> Date: Tue, 19 Jan 2016 11:49:41 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 MIME-Version: 1.0 In-Reply-To: <12.0F.20254.2D29D965@pb1.pair.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC] Allow specifying keys in list() From: lester@lsces.co.uk (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 to list() for object > destructing, but I'm not sure I'd be happy with that, as list() has > thus far been an array-only thing. 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. My real world example is from probably 15+ year old code which has to be re-factored these days to actually work. It creates an 'object' or list of objects as a multi level array to pass around and then uses extract() to give a set of variables some of which may be arrays themselves .... and some 'NULL' entries ... depending on just what the template is building. The 'parsing' will select a function depending on the type of a resulting element and perhaps pass on the extracted array if that is what is provided. I understand that modern practice is to actually define all the values being used ( and type them ) but the flexibility that used to be available seems to be lost by some of these new approaches when one now expects an array of 'objects' rather than an array of 'elements' ? I think that your 'destructuring' is the difference between my simply using the array value and having to find the value of a private variable in the object? Since I am invariably working with associated arrays, 'list' is not something in my toolkit, which is why using it will require rethinking, but simply tidying 'extract' to create a matching set of variables inside the object would make sense in my method of working. Every persistent object comes into me as an associated array, so I'm trying to see how this might improve my own code since the current practices are no longer PC. -- Lester Caine - G8HFL ----------------------------- Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk Rainbow Digital Media - http://rainbowdigitalmedia.co.uk