Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:101708 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 92340 invoked from network); 26 Jan 2018 21:39:31 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Jan 2018 21:39:31 -0000 Authentication-Results: pb1.pair.com smtp.mail=tendoaki@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=tendoaki@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.170 as permitted sender) X-PHP-List-Original-Sender: tendoaki@gmail.com X-Host-Fingerprint: 209.85.213.170 mail-yb0-f170.google.com Received: from [209.85.213.170] ([209.85.213.170:35985] helo=mail-yb0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 45/69-35287-310AB6A5 for ; Fri, 26 Jan 2018 16:39:31 -0500 Received: by mail-yb0-f170.google.com with SMTP id v12so712100ybl.3 for ; Fri, 26 Jan 2018 13:39:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=kl4UfNDeGdwkk1TSL03GdtisGSU7NKa462UZuziJjYw=; b=sIh60t5n8vc0v23JU4Og371dIX9rtA1gOt6Po8agmtOlB85RzAapeCJ3ezp7U5fXh9 sogqrprtSV29k6kG9i0/KTeLteWWiTugDo2z6Zb4UrOFbu5uZ8CdohkvBUFu6/29OvsV laphmpzi0JWHMFGczTvYPXrhhkaRhLUfyNHhpjuyFWjf0SAO23c/49j5UY5uWAeeaHj+ FpA1cKn+JOh/QxPGKXwMmvQfJdqz3WW92xkmceKH4/0czti7by+g847i/pwWIa66d3b4 n5rkPr+iTiyzglGsjIDS4J9H9aVseNRehAOvSoSx9YYtB7ULTR9dM7i6qBRippd2/sZR l9JQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=kl4UfNDeGdwkk1TSL03GdtisGSU7NKa462UZuziJjYw=; b=CqF71lS3Ck/LD6B4wY9TYBdwjZyCziaUnxzRDpYixfmIxxm5yGZ/nhj+H4enmWBci+ 4Hv0hn0VO9DpB91d3h448lwvY+mfTz90Pw/xHx1hLF1yU51cnyYujVQMcUrJymk8bRpd KUydACIrK43xsvw0eE9NpbzQV668I1Js7XoT3/Q1dctpjXY/ZhNaTiVCAYyxlNaE1I/D JkILTmKlNPCrj0iK2kq26g3Gwv127+DDmi8xUZEe7BJCsybJVSxuLXgvpKer+ynIUax4 8JSKF8Kp9iZFQbZqTF9yKAdexUQ7cQsLKu7UhYuh+daBF8esKGsDsGo1RYfP8e28PV9i d2Kw== X-Gm-Message-State: AKwxytdOIlfIRR9+G4csby1k0yRvXhKitv7LHlomHGh0bmA/rp77IM9U N9IFQfbpz9DWt8bwGt0/B9TEguXX397jrJsxcKw= X-Google-Smtp-Source: AH8x226RGfd0x7MmY3oeMD83BfpUhMrHVwEPyLqF3QAqlNH2n895XlehKHJlFOKram8/znRcM7JC4RsYIQsyJWWy6hk= X-Received: by 10.37.12.193 with SMTP id 184mr12209261ybm.516.1517002768731; Fri, 26 Jan 2018 13:39:28 -0800 (PST) MIME-Version: 1.0 Received: by 10.37.189.16 with HTTP; Fri, 26 Jan 2018 13:39:28 -0800 (PST) In-Reply-To: <517F0F7B-CD01-4F35-9021-8336B7BA06E1@cschneid.com> References: <517F0F7B-CD01-4F35-9021-8336B7BA06E1@cschneid.com> Date: Fri, 26 Jan 2018 15:39:28 -0600 Message-ID: To: PHP Internals Content-Type: multipart/alternative; boundary="001a113e62782754cc0563b4bb20" Subject: Re: [PHP-DEV] Shorthand proposal for associative arrays From: tendoaki@gmail.com (Michael Morris) --001a113e62782754cc0563b4bb20 Content-Type: text/plain; charset="UTF-8" Forgot something in the previous post... On Fri, Jan 26, 2018 at 12: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 > The most similar extant feature to this is compact, but it's not as compact as this syntax. $src = 'my.jpg'; $alt = 'My alt'; html::img(compact($src, $alt)); will accomplish the same thing since compact does the reverse of extract - it pulls the specified variables from the local scope and puts them into an associative array. --001a113e62782754cc0563b4bb20--