Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:101711 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 98112 invoked from network); 26 Jan 2018 22:44:26 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Jan 2018 22:44:26 -0000 Authentication-Results: pb1.pair.com smtp.mail=richard@jenningstechnology.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=richard@jenningstechnology.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain jenningstechnology.com designates 209.85.218.47 as permitted sender) X-PHP-List-Original-Sender: richard@jenningstechnology.com X-Host-Fingerprint: 209.85.218.47 mail-oi0-f47.google.com Received: from [209.85.218.47] ([209.85.218.47:37142] helo=mail-oi0-f47.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 43/7A-35287-74FAB6A5 for ; Fri, 26 Jan 2018 17:44:24 -0500 Received: by mail-oi0-f47.google.com with SMTP id t78so1339803oih.4 for ; Fri, 26 Jan 2018 14:44:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jenningstechnology-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=mKYSrrk+T2LDMSd54w9MmWrRt9ywYVI+VDxjrG4FAN4=; b=q2HdwHBhVcuGedo0nexD4RU4dtBkR7ja7TDnKO48iB10HJz+6hdqAhqDzZWEgeGLbF 7iSZmJ6wRZF/eijjqNx9HaAl/90RzOlzg9WjN2r9PdgmDgImGhWXztGzxlEyauYzuhm+ LeiWxto7ljz/iv7S8oyjlaBEOMytk8pp7xjv+HQIRDUfOkgOq71Vr48nW2ZcKvh1Tegw 0TV6cnrYBLqx6ivJkKrBGNtkiASuzUR60diSDNqBUBcs8of9WdGoEyUvBXj37rahSs4r lNcTzruE3USaVW7J4wLejHzh4Dpsj2IWWknwulh8FNxNHdZ2s8/vKcULy43z20YA6s8L 3MBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=mKYSrrk+T2LDMSd54w9MmWrRt9ywYVI+VDxjrG4FAN4=; b=E3L9p6euFHOD3oS/6je1CQJzseyHua6FNPbOjJAT0udqAcJ84p1QhEUzjzJ7ZI830N k+Ke9vW/0bo1S/4ao5W2Gm/XTvL+aAJGJlVDZqLXaw6ELaK0MyezdVLeaUsuRtY6kjBL aA0/waYMYdO2arYlKLfDdjXfjvMM2CTND+Mekau2jFj3FobiFBBU4roUjmNiE8CakGlO BqyKvIIg/2F1JX6lrP4oEjhxmOJA4xp7ZzcgWVXruk0OKiG4ifJ1nPbOvIEf0BS8Lf0t rxaG6/AXTflXPjXFC4wj9zyGoorBCRzIJd7pvQjcEf4YogWCQFp8RqiDgAbp6VEn85va MxxA== X-Gm-Message-State: AKwxytfFQ1LGRTEabh7cT8RXpg5DB8RPY8uL5nbwBczAOW5OD12RSoHz VhSAPDI9lq+VR0j16BoZczpRKRFPkFS3L9dk8CVJyA== X-Google-Smtp-Source: AH8x226l3YU177YtRCCR15PfPgAIU2B4FjqGg4vVo61EjMQTTZiD+kBBedK9yqpa6usWdfAiuxXW6eq+dqW+P3iakPc= X-Received: by 10.202.64.69 with SMTP id n66mr12424750oia.218.1517006661241; Fri, 26 Jan 2018 14:44:21 -0800 (PST) MIME-Version: 1.0 References: <517F0F7B-CD01-4F35-9021-8336B7BA06E1@cschneid.com> <620452cc-09eb-ec95-bf8d-e1cddee988f1@fleshgrinder.com> In-Reply-To: <620452cc-09eb-ec95-bf8d-e1cddee988f1@fleshgrinder.com> Date: Fri, 26 Jan 2018 22:44:10 +0000 Message-ID: To: internals@lists.php.net Content-Type: multipart/alternative; boundary="001a113dd9622a64040563b5a314" Subject: Re: [PHP-DEV] Shorthand proposal for associative arrays From: richard@jenningstechnology.com (Richard Jennings) --001a113dd9622a64040563b5a314 Content-Type: text/plain; charset="UTF-8" In my opinion this suggestion reduces readability and increases cognative burden and as such I hope it is not included. Regards On Fri, 26 Jan 2018 at 21:52, Fleshgrinder wrote: > On 1/26/2018 7:16 PM, Christian Schneider wrote: > > Hi there, > > I have a proposal for a shorthand notation of associative arrays > borrowed from another language: > > :$foo > > would be equivalent to > > 'foo' => $foo > > and would work with array, list or [] > > > > Motivation behind it, maybe someone else finds more good uses: > > > > 1) Emulating named parameters with associative arrays like > > html::img([ 'src' => $src, 'alt' => $alt ]); > > could be written as > > html::img([ :$src, :$alt ]); > > which encourages consistent naming of variables and parameters > > > > 2) Simplifying list destructuring with non-integer keys, example taking > from > http://php.net/manual/en/migration71.new-features.php#migration71.new-features.support-for-keys-in-list > > foreach ($data as ["id" => $id, "name" => $name]) { > > becomes > > foreach ($data as [ :$id, :$name ]) { > > which reduces redundancy. > > > > I implemented a minimal patch (2 lines are added to the parser) to > implement this which you can find at > > https://cschneid.com/php/php7_2/assoc_array_shorthand.patch > > > > What do you think, is this worth an RFC? I hope I didn't miss an > existing one :-) > > > > Regards, > > - Chris > > > > > > Hi Chris! > > I really like this proposal. `compact` is cumbersome to use, or lets > say, almost impossible without an intelligent IDE. However, what is more > important is the fact that is would allow for a very readable and usable > approach for destructuring of associative arrays (as illustrated by your > example) which is very, very neat. The change is also extremely minimal > which speaks for it. > > I would support you in writing up an RFC for this (if desired). > > -- > Richard "Fleshgrinder" Fussenegger > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Richard Jennings Jennings Technology Limited Company Number: 09827512 VAT Number: 224 8864 84 --001a113dd9622a64040563b5a314--