Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:90714 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 79720 invoked from network); 19 Jan 2016 12:55:17 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Jan 2016 12:55:17 -0000 Authentication-Results: pb1.pair.com smtp.mail=leight@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=leight@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.179 as permitted sender) X-PHP-List-Original-Sender: leight@gmail.com X-Host-Fingerprint: 209.85.213.179 mail-ig0-f179.google.com Received: from [209.85.213.179] ([209.85.213.179:37760] helo=mail-ig0-f179.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 01/42-61693-4323E965 for ; Tue, 19 Jan 2016 07:55:16 -0500 Received: by mail-ig0-f179.google.com with SMTP id h5so65721388igh.0 for ; Tue, 19 Jan 2016 04:55:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=iP/gaNc9XnuC5G6B0fmOs97piyYdqt1NX4iGgZ4qrIw=; b=ur0AN6dpxwAmmzr4zX8qiQzU5DhSRc/15DyMzkxRPPjLI1fj1iZDDTEYthd/OY8zWC 9c/ZXBpKLyD8wmCm3bC4tAj6n5aOpSvR/8V6RyF43e0FTppnwryfLcLoTn6v+ET2SIWR n/xKvaLyhxVm6/bcdluvDnKjjnpglS4wcxvzuuokBkpj5SI3vXTUkQu9F7womX23XLbn B035D6G2Xv1uo7tkZJTTdTCBaIpdDl6p0vYmanCXJNDTqfdYa0S5JtaIuXNQR24rgpcv mfVuv+T5r1VcM3QNNHxJi5NKuuQyUW+sMorPZeJHcvGXPGtUK5bpBw1hdQO5QAofBdxi CBag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=iP/gaNc9XnuC5G6B0fmOs97piyYdqt1NX4iGgZ4qrIw=; b=hS2DcL0j41UJD6d2DLJjdTNMK2kj7jyv+MrxKgUmKzUc0/5Un6hsnc0xMU45HYyjZm vU18fwKKqV3DyaxzeSgEvjBPgz9NszLXFbz/G7x7Ffif3UPeEJ+tLcffEFzZ3jrdZ8+V 4NdAgxBB7ugpGzIKIk4GUlGUYxPtC787TcY6Yqniu9HLr7hX6gWfPh0qGJcvxrOwK8tn n9iK9df6agFJS67vRSJD2wXT7qZHYgp3H6DMN3LPATqkOpVaig8/1tAtQ9wgvyExgsuH t8w1li0Q0AOiMlxcWjWw9MNQQ8v+JCFOA+tq8aHl2CT2SyPorkHbQb9pIUefOixSBS8e eYKA== X-Gm-Message-State: AG10YOT1eIQ3es82/E4b0QeW3K63js0Xvb5MDGWxIZqeQQn8hcZ+wNEILdP0qalNdO+Wm3l2KF/49iWJLXZ1nw== MIME-Version: 1.0 X-Received: by 10.50.28.19 with SMTP id x19mr15884488igg.92.1453208113954; Tue, 19 Jan 2016 04:55:13 -0800 (PST) Received: by 10.36.95.210 with HTTP; Tue, 19 Jan 2016 04:55:13 -0800 (PST) In-Reply-To: <37.10.20254.67D9D965@pb1.pair.com> References: <3B.E6.32157.D3DFA965@pb1.pair.com> <569C91FE.8030605@php.net> <569CDC1C.2070304@lsces.co.uk> <43.5E.20254.1B65D965@pb1.pair.com> <37.10.20254.67D9D965@pb1.pair.com> Date: Tue, 19 Jan 2016 12:55:13 +0000 Message-ID: To: Andrea Faulds Cc: internals@lists.php.net Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] [RFC] Allow specifying keys in list() From: leight@gmail.com (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 complicated), it's not something likely to be used in practice, and I > think it's probably an indicator of bad code. > > Now, I can understand your case, but I don't really want to add a special > exception for it. If we're allowing keyed or unkeyed, not both, then we > should stick to it. > > Also, I realised that in your case (`list(7 => $a, $b, $c, $d)`), there are > other, possibly cleaner ways to do it, such as: > > list($a, $b, $c, $d) = array_slice($array, 7); > > This way is simple and clear. It's probably clearer than `list(7 => $a, $b, > $c, $d)` in fact. There's also this: > > list(($i = 7) => $a, ++$i => $b, ++$i => $c, ++$i => $d) = $array; > > This way is horrible, but at least demonstrates there are other ways to > achieve what you want. Thanks, I wouldn't worry about it. The use-case was hypothetical anyway. I could see how I might use it, but I have nowhere at present I'd actually use it. list($offset => $a, $b, $b, $c) = $array; $offset += 4; vs. list($a, $b, $c, $d) = array_slice($array, $offset); $offset += 4; Probably not worth the complexity overhead as you suggest, for what amounts to (arguably) syntactic sugar. I also doubt it would see enough usage to warrant the small gain of avoiding the fcall there.