Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:101715 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 56728 invoked from network); 28 Jan 2018 02:51:16 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Jan 2018 02:51:16 -0000 Authentication-Results: pb1.pair.com header.from=cschneid@cschneid.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=cschneid@cschneid.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain cschneid.com from 62.12.172.119 cause and error) X-PHP-List-Original-Sender: cschneid@cschneid.com X-Host-Fingerprint: 62.12.172.119 darkcity.gna.ch Received: from [62.12.172.119] ([62.12.172.119:46884] helo=mail.gna.ch) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DC/72-24062-0AA3D6A5 for ; Sat, 27 Jan 2018 21:51:15 -0500 Received: from [10.0.1.55] (77-56-180-37.dclient.hispeed.ch [77.56.180.37]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by darkcity.gna.ch (Postfix) with ESMTPSA id 86D8135F92; Sun, 28 Jan 2018 03:51:09 +0100 (CET) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 11.2 \(3445.5.20\)) In-Reply-To: Date: Sun, 28 Jan 2018 03:51:08 +0100 Cc: PHP Internals Content-Transfer-Encoding: quoted-printable Message-ID: <39BA1B12-D1EB-4348-8DD6-FE73B22047D8@cschneid.com> References: <517F0F7B-CD01-4F35-9021-8336B7BA06E1@cschneid.com> To: Sara Golemon X-Mailer: Apple Mail (2.3445.5.20) Subject: Re: [PHP-DEV] Shorthand proposal for associative arrays From: cschneid@cschneid.com (Christian Schneider) Am 28.01.2018 um 00:29 schrieb 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. >>=20 >> So the real example is: html::img(compact('src', 'alt')); >>=20 >>> On Fri, Jan 26, 2018 at 12:16 PM, Christian Schneider = wrote: >>>> 1) Emulating named parameters with associative arrays like >>>> html::img([ 'src' =3D> $src, 'alt' =3D> $alt ]); >>>> could be written as >>>> html::img([ :$src, :$alt ]); >>>> which encourages consistent naming of variables and parameters >>=20 > I see nothing in this proposal that compact doesn't already do quite = well. Yes, it is syntactic sugar to remove verbosity. Using compact() has two = problems for me: 1) It is verbose especially if the assoc-as-poor-man's-named-parameter = approach is used frequently. A bit like array() vs. []. 2) More importantly: It hides the variable being used: 'src' instead of = $src which makes it harder to search for the variable or statically = analyse the code. - Chris