Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:101714 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 50296 invoked from network); 27 Jan 2018 23:29:44 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Jan 2018 23:29:44 -0000 Authentication-Results: pb1.pair.com header.from=php@golemon.com; sender-id=softfail Authentication-Results: pb1.pair.com smtp.mail=php@golemon.com; spf=softfail; sender-id=softfail Received-SPF: softfail (pb1.pair.com: domain golemon.com does not designate 209.85.220.177 as permitted sender) X-PHP-List-Original-Sender: php@golemon.com X-Host-Fingerprint: 209.85.220.177 mail-qk0-f177.google.com Received: from [209.85.220.177] ([209.85.220.177:43817] helo=mail-qk0-f177.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 47/E1-24062-56B0D6A5 for ; Sat, 27 Jan 2018 18:29:42 -0500 Received: by mail-qk0-f177.google.com with SMTP id a5so1428932qkg.10 for ; Sat, 27 Jan 2018 15:29:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=golemon-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=fmPbrBTR17mgSfpHvngRgWpC6BfrtvkcWlOA7/HeB0c=; b=ulzSGvHkRmiFvQOIdhICbEO3AoZW7cVl6Eil8fx4QM66uHNtDt8EZ4U3Vbc8S3TPcX EczRm+Pp0+sVEtdDwxRQD/fGrxH0m/BxRAXcazJZR0JTf93Fln840kahNNDQCxPqMSgt I9ObVNFkoleK1Ba+FnSjRBYCirxXAKYKY3e1mh3fNJ4rsS+yHOOkXQmfLscjG2n7Y9Cu c3qkrQ+/xOKyGye4eciq2qAWbZxWz0hipfhFl6buIBfGIGiAphVCqLNi/5fqeXQqiAK6 Hc0t9o8pUoiYJCE6M6pfOm1txCRprgwW1Vo3+K1bAlHNnKSGRQhpV60/TkXiYLvMYvgT vKEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=fmPbrBTR17mgSfpHvngRgWpC6BfrtvkcWlOA7/HeB0c=; b=auUnjO1FR81ZdfirDoJpBZ/37+zXHiRIZhfvMvYAQPbQjoClepGjObS8GvTEGV6s/O a98l6h62ve9q3JwL175q7VGNAN8DAE2VLxIsFj4RpdnwoGsMdMPo1O6RFd2JjE7sGG8E n2UOnLQiVY04ALbYPZ3HW5S4vrg0kRS2ePVguccZv/QetnBLdFJn5uFoUAlS3VXaXfBT 52Si2rCYsQqi21yXnxrIjvax03LU1UspwNdQ5THBJkDI+tN3pBrMddF797R1Q53g0A+5 Q0nZyU2B6M3zRZLQUHRTg/CfL948zZDu/qQWddSjo/QIo0/+0262Et36kgbd09NNtZXQ I9MQ== X-Gm-Message-State: AKwxyte4Owf3gKYuuPVexPa/4k929nVqbbM08mrY7CI+JhvgCkXi3XsC nOyMCSdfKTHcZPuhEQYwGVYym/YNd0L6vIdMxyWjrA== X-Google-Smtp-Source: AH8x2255Ua9ZUvbNgjI+EcgUZpUn+0JDEhe9T/kXcJ9gRp0xPipMVxkYogiMpIhEPIQ3JCNbaNOrzJMqn+SWRDxbo1s= X-Received: by 10.233.214.3 with SMTP id r3mr28337906qkk.81.1517095778600; Sat, 27 Jan 2018 15:29:38 -0800 (PST) MIME-Version: 1.0 Sender: php@golemon.com Received: by 10.12.197.144 with HTTP; Sat, 27 Jan 2018 15:29:38 -0800 (PST) X-Originating-IP: [206.252.215.26] In-Reply-To: References: <517F0F7B-CD01-4F35-9021-8336B7BA06E1@cschneid.com> Date: Sat, 27 Jan 2018 18:29:38 -0500 X-Google-Sender-Auth: Iiv-n87tGLrtOVCfg1gYLXVjBqU Message-ID: To: David Rodrigues Cc: Michael Morris , PHP Internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] Shorthand proposal for associative arrays From: pollita@php.net (Sara Golemon) On Fri, Jan 26, 2018 at 4:49 PM, David Rodrigues wrote: > 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. >> > I see nothing in this proposal that compact doesn't already do quite well. -1