Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:101707 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 90891 invoked from network); 26 Jan 2018 21:31:55 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Jan 2018 21:31:55 -0000 Authentication-Results: pb1.pair.com header.from=tendoaki@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=tendoaki@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.172 as permitted sender) X-PHP-List-Original-Sender: tendoaki@gmail.com X-Host-Fingerprint: 209.85.213.172 mail-yb0-f172.google.com Received: from [209.85.213.172] ([209.85.213.172:33165] helo=mail-yb0-f172.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A3/19-35287-94E9B6A5 for ; Fri, 26 Jan 2018 16:31:54 -0500 Received: by mail-yb0-f172.google.com with SMTP id w3so706895ybg.0 for ; Fri, 26 Jan 2018 13:31:53 -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=PLFTF3ohzTK+9pg2MC3jk4C5ovy7IaQkGC7E+oaWUEA=; b=AOwA/PbFVJkjS4E40IirusqG39NoYKQ+qZBkrfmkvG7Q3Yl7wrE0zLWjTRiNJq7WsD MTJ351TMxqoWJdZxLdGv8WK1LS2rGd/hmKOIjcxJepYKrjv/9Qg7XDEwDilKd9Np/5q4 2Ao4LNz6/k1qvn1CLYVGpO3cEwWKKECDq3xAQ9xBaJbMMhMJady+KKhSAoIWrzvqJ9Ka a1KY44Up27bvpZ8ZDp7hnTI73DpPuTjxh0GQO3J5/AJz6d0ymXxgIkH8G9CjMxIaxp0i W8aMbUaQpSNyPfwNBEKwB8DHvkW+1WoHmvGKSwFXsA7mis7gz/kwhkKeN2cEm3l0+Tec MPCg== 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=PLFTF3ohzTK+9pg2MC3jk4C5ovy7IaQkGC7E+oaWUEA=; b=jICxFqV8DQh7kd0MNt3+2huqevmNrJ9aM6/bVMETc1uSlD8AUMylBQNP7FNmVIc1II Q1ydieRZP8PPbGRPOf6BHT7aH0c6gCfSnxU5ZlWNMw9571VE77nsRvwcMmPPWjoe2pWr MP9m+L1YZryXWm4bVUQ7QhhH4zZlzwPf64Wva0rnyRI7XCd+yWx97FMAd82QHlkWBcXr 1Lt637pxpuAzF+5Cwxg3OcKeSEXf+ZzBMagEt/+8ZkzxNZOnU2vm8/9VnIw0jWcUMnnq CWD3iV8V237ouVbMbmUCezNvAIYVYPslaCdjOthLBLYmDvqFaU3oxAyzAthql8dmqkFJ gQug== X-Gm-Message-State: AKwxytdcmuTuOgmZzo635gwfaId8lBtlgaAPMJUNnHPeiGiOpbpb0Wzl F9Tcc2x2IWniOMz5CvBt8WCJ9nM3v7hZkpu9Lp0= X-Google-Smtp-Source: AH8x224JCTx2w4/9UXMfLPkwtUT0WEAIhDNkwpA3QuCAFeaPCE38XTYglLBCjHL1EADBjFwcGjXaGaIdgU/j+043ZGQ= X-Received: by 10.37.164.103 with SMTP id f94mr12024847ybi.129.1517002310399; Fri, 26 Jan 2018 13:31:50 -0800 (PST) MIME-Version: 1.0 Received: by 10.37.189.16 with HTTP; Fri, 26 Jan 2018 13:31:50 -0800 (PST) In-Reply-To: References: <517F0F7B-CD01-4F35-9021-8336B7BA06E1@cschneid.com> Date: Fri, 26 Jan 2018 15:31:50 -0600 Message-ID: To: David Rodrigues Cc: Christian Schneider , PHP Internals Content-Type: multipart/alternative; boundary="f403045c562ed5bdfd0563b49fad" Subject: Re: [PHP-DEV] Shorthand proposal for associative arrays From: tendoaki@gmail.com (Michael Morris) --f403045c562ed5bdfd0563b49fad Content-Type: text/plain; charset="UTF-8" On Fri, Jan 26, 2018 at 2:00 PM, David Rodrigues wrote: > Maybe you should see the extract() method. Uhm, what? You need to learn what extract does before you recommend it as an alternative to someone's proposal. Extract takes an array and moves their keys onto the local symbol table. So extract( ['src' => 'myimg.jpg', 'alt' => 'My alt']); echo $src; // myimg.jpg echo $alt; // My alt Using extract on an array with numeric keys gives you fun stuff like $0, $1 and so on. Extract sees most of its use in PHP based template management classes where an associative array is extracted than a template file is included, to allow the template file to use the key names as variables rather than the array syntax. As to the proposal itself. > 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 I've been mulling this over since I saw it earlier today. It's kinda neat to be honest. --f403045c562ed5bdfd0563b49fad--