Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:90716 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 94324 invoked from network); 19 Jan 2016 16:20:36 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Jan 2016 16:20:36 -0000 Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.52 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 74.125.82.52 mail-wm0-f52.google.com Received: from [74.125.82.52] ([74.125.82.52:34091] helo=mail-wm0-f52.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8B/14-61693-3526E965 for ; Tue, 19 Jan 2016 11:20:36 -0500 Received: by mail-wm0-f52.google.com with SMTP id u188so150220572wmu.1 for ; Tue, 19 Jan 2016 08:20:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-type:content-transfer-encoding; bh=SgZ22mTXdI6lxyROM6dJzV456ivUYQ2d+YDEz96x38A=; b=fjLHtp02RIJsc6n9KPpJo+JwR8m28sZGmEJnqWTr7P4fyqYAZYwcHfI1DFAnhUPmuX maGo9VBgaKKyVRTGzgOdS1SMO1fIGUNdV8EH6q505Ye8gMQizs2B3IUKVk+ZFT9VfhMe DUzOnqpCxfC7oNDVcSliBwUEcMNZ22a3K4BZSarr69c2RlLdTuDwH+n3EBhqpEnAPJYV vHYPT+t8UZf+WKKR67/WmfPlO72VS444tT4pQzxGxxJzDWNOrkgKOIyYuz27kjesGiKL CE7FaCtmqcp+gTJOMGJ1wTv2ttJ+3m8xIzyrU6P72PrBD/Z5I16RlDOpOs/Bv/KNF74r Nt4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-type :content-transfer-encoding; bh=SgZ22mTXdI6lxyROM6dJzV456ivUYQ2d+YDEz96x38A=; b=kV9o/DHeCnlWeUnUzrcsKqZ7hPk9xOx2ScsKyZVI5tI2dD/vcXb5RNI3PMLdDv3ZcS oUoZ+XTZl+e+PXhbtVy7jXw+psZ5Uuk3b/3obIBwqGpKMWxqwKSCINZc532zPhYZrzDn VcD1gwPgiGh77Xclefi3ChviOkE1bgpVzgXFXfZ9SYUsNP0etnf692FD7ME9PIMzN+ZT 6YQEIvvWVLCEao4z6QO8vujxsViCuTabkczYIyC2bocVvEwATcGsK8CMMGPC2F9QS/h5 ki0pcuEB9XeKHmw2abErOJ2OfSQYLtAtZfXUrfsr0cF6I8gew+3J0gGoqzSzzIzPdiSu 6kwQ== X-Gm-Message-State: AG10YORhNdBOz3CCrqPUTYbV3jXERb8CzWhKpictTMzsP64DO9T52r47sqofdYmi/ecE1A== X-Received: by 10.194.52.37 with SMTP id q5mr23941588wjo.123.1453220433041; Tue, 19 Jan 2016 08:20:33 -0800 (PST) Received: from [192.168.0.177] ([93.188.182.58]) by smtp.googlemail.com with ESMTPSA id uo9sm29171962wjc.49.2016.01.19.08.20.31 for (version=TLSv1/SSLv3 cipher=OTHER); Tue, 19 Jan 2016 08:20:32 -0800 (PST) To: internals@lists.php.net References: <20160118131911.DA1832607EC@dd15934.kasserver.com> <12.0F.20254.2D29D965@pb1.pair.com> <569E22D5.4040900@lsces.co.uk> Message-ID: <569E61EC.5040809@gmail.com> Date: Tue, 19 Jan 2016 16:18:52 +0000 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <569E22D5.4040900@lsces.co.uk> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC] Allow specifying keys in list() From: rowan.collins@gmail.com (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 something similar to what you can do in JS: // Object literal: create an object with all its values var foo = { a: 1, b: 2, c: 3 }; // Destructure an object into variables: take bits of an object that you're interested in all in one go // equivalent to bob = foo.a; jane = foo.c; var {a: bob, c: jane} = foo; In PHP, we don't have either of these on objects - you can only create an object using a constructor function - but the proposal is basically the same thing for associative arrays (which are in some ways similar to JS objects anyway): // Array literal $foo = ['a' => 1, 'b' => 2, 'c' => 3]; // Destructuring with list() list('a' => $bob, 'c' => $jane); So it's like extract(), but both more powerful and less dangerous - you don't get an unexpected variable $b when someone adds a key to the array, and you have the ability to rename $a and $c while you're extracting them. It may or may not work for your use case, but it doesn't really have anything to do with objects either way. Regards, -- Rowan Collins [IMSoP]