Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:60966 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 29691 invoked from network); 26 Jun 2012 02:59:08 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Jun 2012 02:59:08 -0000 Authentication-Results: pb1.pair.com header.from=aaron@aaronholmes.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=aaron@aaronholmes.net; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain aaronholmes.net from 209.85.214.170 cause and error) X-PHP-List-Original-Sender: aaron@aaronholmes.net X-Host-Fingerprint: 209.85.214.170 mail-ob0-f170.google.com Received: from [209.85.214.170] ([209.85.214.170:41942] helo=mail-ob0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 23/4B-56161-97529EF4 for ; Mon, 25 Jun 2012 22:59:06 -0400 Received: by obfk16 with SMTP id k16so8832236obf.29 for ; Mon, 25 Jun 2012 19:59:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:x-gm-message-state; bh=UrsyI6+oMYdLJREpPY5dXmTHiQCAK0n/ux6Yvw2evJE=; b=kLsD10VaxELp6e23/tJ2LTJVWeRkXb+NFtJkoO+lovcIOmLU2hdwC9bXCMRehLlrHV wEVfRntPfrZ/t3WavLN4RUzNNPuGS97OLCDpVp4xSvadK6atMDBTyUEsPAZVObpd0UBU 9Vb3yDHWW7PibNZSDZUlPBzZzfq1a7CD2IitoH1CgRTtTM/gvZYbKP1C69eGxRDZORia jHg7oMuQnXdFu1UPp4dse/8rG6xz9TwMPDpaznt/IlpGWISs9rCo1QvE5rgyj3w2V6eX zneK9FD8NY1Ycn3Z1ut0fRUjR2En2fiOjZ3SFBQJ92hvrlPmvZNJyxS6CqhKdtSsxqB3 NrdQ== Received: by 10.182.36.102 with SMTP id p6mr14345485obj.77.1340679542822; Mon, 25 Jun 2012 19:59:02 -0700 (PDT) Received: from [192.168.1.64] (99-51-144-231.lightspeed.irvnca.sbcglobal.net. [99.51.144.231]) by mx.google.com with ESMTPS id l10sm3091528oeb.13.2012.06.25.19.59.01 (version=SSLv3 cipher=OTHER); Mon, 25 Jun 2012 19:59:02 -0700 (PDT) Message-ID: <4FE92578.3020509@aaronholmes.net> Date: Mon, 25 Jun 2012 19:59:04 -0700 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20120428 Thunderbird/12.0.1 MIME-Version: 1.0 To: Paul Dragoonis CC: internals@lists.php.net References: <4FE3759D.4010606@php.net> <4FE449BA.9040108@leo-peltier.fr> <4FE494A9.5040605@php.net> <4FE62A6A.9030901@sugarcrm.com> <3D.D4.56161.13978EF4@pb1.pair.com> <4FE8BA77.9040901@php.net> <4FE8CAAD.3030002@aaronholmes.net> In-Reply-To: Content-Type: multipart/alternative; boundary="------------020906000206070105010309" X-Gm-Message-State: ALoCoQlI8KKZHfin7gu+Bgx7IRzZze5hwF4phTfg51dpf2k92uS2dYhpjRi0RoA6PmwbL3Q98jIu Subject: Re: [PHP-DEV] [DRAFT] RFC - array_column() function From: aaron@aaronholmes.net (Aaron Holmes) --------------020906000206070105010309 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit The name makes sense, but would likely be confused with extract() http://us3.php.net/extract On 6/25/2012 5:35 PM, Paul Dragoonis wrote: > What about array_extract ? > > On Mon, Jun 25, 2012 at 9:31 PM, Aaron Holmes > wrote: > > For what my .02 is worth, I imagine "plucking" an item out of an > array would not occur to a user-land developer as the proper > nomenclature for extracting all the values from an array with the > given key. At worst, this means many developers simply won't learn > about the function and continue to implement it in user-land. > > When array_column was offered as the name, I immediately knew what > the purpose was, before checking the RFC. > > > On 6/25/2012 12:22 PM, Ben Ramsey wrote: > > On 6/25/12 9:44 AM, Matthew Weier O'Phinney wrote: > > On 2012-06-23, Stas Malyshev > wrote: > > I'm open to changing or aliasing the name to > array_pluck(), if others > are in agreement. > > > I wouldn't know what "pluck" means here. "Column" is a > clear word with > established meaning. Let's not get too whimsical here. > > > Nothing whimsical about it at all, Stas. The definition is: > > Take hold of (something) and quickly remove it from > its place; pick > > and synonyms include "pull" and "gather". > > As Ralph noted, "column" is overloaded, as it has > connotations dealing > with databases as well as tables, and arrays often > represent neither. > > > I agree with Tom and Ralph that we should look at what others > are doing and pick a similar name. After searching on "pluck," > though, I'm getting mixed results on how pluck is used: > > In Rails, it looks like pluck is used for the purpose that > I've created array_column, but it's used with ActiveRecord as > a way to pull a column of results from the database (much like > PDOStatement::fetchColumn). See here: > > https://github.com/rails/rails/commit/a382d60f6abc94b6a965525872f858e48abc00de > > > However, in Prototype.js and Underscore.js, pluck seems behave > more like array_map() in PHP: > > http://api.prototypejs.org/language/Enumerable/prototype/pluck/ > http://documentcloud.github.com/underscore/#pluck > > Nevertheless, it would technically have the same effect as the > "column" functionality, since calling that method/property in > Javascript simply returns the value of the property or result > of the method call. > > Also, the Python community has recently discussed adding pluck > for lists: > > https://groups.google.com/forum/?fromgroups#!topic/python-ideas/p9qtUzg9zsk > > > > It looks like they already have some functionality that > implements similar behavior, though: > > >>> stooges=[{'name': 'moe', 'age': 40}, {'name': 'larry', > 'age': 50}, {'name': 'curly', 'age': 60}] > >>> names=[guy['name'] for guy in stooges] > >>> print names > ['moe', 'larry', 'curly'] > > array_column/pluck in PHP would do the same: > $names = array_column($stooges, 'name'); > > If other languages/frameworks/libraries are using pluck to > mean exactly what this implementation means, then I agree with > changing the name to array_pluck, but if "pluck" also carries > meaning similar to array_map, then I don't want to confuse folks. > > -Ben > > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --------------020906000206070105010309--