Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:101709 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 93915 invoked from network); 26 Jan 2018 21:49:34 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Jan 2018 21:49:34 -0000 Authentication-Results: pb1.pair.com header.from=david.proweb@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=david.proweb@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.48 as permitted sender) X-PHP-List-Original-Sender: david.proweb@gmail.com X-Host-Fingerprint: 209.85.214.48 mail-it0-f48.google.com Received: from [209.85.214.48] ([209.85.214.48:52722] helo=mail-it0-f48.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 96/B9-35287-D62AB6A5 for ; Fri, 26 Jan 2018 16:49:33 -0500 Received: by mail-it0-f48.google.com with SMTP id u62so2134016ita.2 for ; Fri, 26 Jan 2018 13:49:33 -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 :cc; bh=0TTXfU9ucRMKOyFAGS7R7G0Ruu+KMYGfeeD5KDSL6bk=; b=LB4ZhJFtC1XgQ6Duww+bYlHaaychrVncbB0H3/56kw/UFYsbNVlhOGvFpmjmPwGiuh j42MltWZlyu146m3SgdZErYRfmxVKvR2GM2P5IQ+O9b+Ih9hXDKdLxANDq1fu1dVxOcn gQh9XE6uA+kPi90APGv46Lb2GQZXnizljIQPDa3csdop521+aYKq2gmnWKeTg96lh9mJ L0run1pj85f6dCVCKI3Nu77w8KXRcZWuB3iVIaMCbH2OSiGGHmfPkxQI4g5fMjMjRSVY 02Mb1SZ2erupG8bT2Vtgwe8o1/QAKfgHkoSeBlxeux6iBkbc9Pam6a5cHTpdQ5us9dNU 6IrQ== 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:cc; bh=0TTXfU9ucRMKOyFAGS7R7G0Ruu+KMYGfeeD5KDSL6bk=; b=Oo445DWIB1PqxB9W2JvxI3NO+MAzU4xzQziTuHvZLiSnH0eQrmIf41CagP5Yo8dEsk Hi6q1GNSygloeE1Izi4IvEpsf1wOX3+out0nANCGB0toS6DJRqIDKFjeIME39Q/2XQU5 a4uIPpuG9EufsHATxVAc5D6pE6y+s/CcNGyKPLaCrtUPL7wvUkcfiefVuNscO+CfarF4 0mNg9IGubpmhjLzCf8suQG0m7c2NrJtNyvkSPgZ4iLW5xXQtwtrTflNs6+J0q+wsHaLJ ZFwvKoOzKp0ABFXHfSTQK11oWYaus94jDoYtzfg3l92uiwzlY5S7XUmzrB+AxcV0NAYW Ih+w== X-Gm-Message-State: AKwxytfDGfzgvmRZ8y/oyG66pBYiK2N5g410bJ24iJdKHfYnxnENyHJw yQC7mM1oJXr4z2o74Gf2kfxvGokSaGHHZ3CIguE= X-Google-Smtp-Source: AH8x226MT/Rdq6Ho4rs/q2cz4YDzkzVLI1UGvTwtq9E1Tdw/jbV1tzmdoRukdjxPHdyiDkDHmGLZ4JSOu7jkA5bDiAM= X-Received: by 10.36.130.198 with SMTP id t189mr16115741itd.45.1517003370536; Fri, 26 Jan 2018 13:49:30 -0800 (PST) MIME-Version: 1.0 Received: by 10.2.48.211 with HTTP; Fri, 26 Jan 2018 13:49:10 -0800 (PST) In-Reply-To: References: <517F0F7B-CD01-4F35-9021-8336B7BA06E1@cschneid.com> Date: Fri, 26 Jan 2018 19:49:10 -0200 Message-ID: To: Michael Morris Cc: PHP Internals Content-Type: multipart/alternative; boundary="94eb2c0897a40623ad0563b4df2c" Subject: Re: [PHP-DEV] Shorthand proposal for associative arrays From: david.proweb@gmail.com (David Rodrigues) --94eb2c0897a40623ad0563b4df2c Content-Type: text/plain; charset="UTF-8" Sorry. I mean "compact()" instead of extract() (it basically does the oposite hehe), I confused everything in a hurry. Sorry. So the real example is: html::img(compact('src', 'alt')); 2018-01-26 19:39 GMT-02:00 Michael Morris : > Forgot something in the previous post... > > On Fri, Jan 26, 2018 at 12:16 PM, Christian Schneider < > cschneid@cschneid.com > > 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. > -- David Rodrigues --94eb2c0897a40623ad0563b4df2c--