Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:60964 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 11157 invoked from network); 25 Jun 2012 20:31:45 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Jun 2012 20:31:45 -0000 Authentication-Results: pb1.pair.com smtp.mail=aaron@aaronholmes.net; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=aaron@aaronholmes.net; 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:60778] helo=mail-ob0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A8/C7-56161-FAAC8EF4 for ; Mon, 25 Jun 2012 16:31:43 -0400 Received: by obfk16 with SMTP id k16so8324738obf.29 for ; Mon, 25 Jun 2012 13:31:40 -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:subject:references :in-reply-to:content-type:content-transfer-encoding :x-gm-message-state; bh=efZHCH6Lz9zhUaJ21wTujV/N+AkJp/j2ZntnXO8PoBg=; b=JcuE6QrNhkvBQwOuwGJ3LPpKNG6qdhtBNB/QVB3J8n01Ek2vNhHsRmQ+qt4wpR/KXb KruX/neSBukBe/Ll/YvH8NfmZllhgxQNg+Al+91HVn7fEscq629HTCym8RwiqgWWi+te 2UKwbyuWvHSQ5FYSiQ2fQeoooAVYhs/XjHCt5Hly3m6xkdAFaaZS9ZcRQgZtoQ++EWyZ nrZWVtZgwinajMvZk7Gw91DSZN19nrRw2TD4QyFdWRvLOd/1LQbYVeKK35HjStYVdt2v faDHZv98KaHl9au4xyO1QEtOHFF9njmK1ie5OOY+JDbMJypAESlnaM2Cwsul96DUk76g hWyw== Received: by 10.182.76.169 with SMTP id l9mr13532320obw.44.1340656299831; Mon, 25 Jun 2012 13:31:39 -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 l9sm26110323oeg.3.2012.06.25.13.31.38 (version=SSLv3 cipher=OTHER); Mon, 25 Jun 2012 13:31:39 -0700 (PDT) Message-ID: <4FE8CAAD.3030002@aaronholmes.net> Date: Mon, 25 Jun 2012 13:31:41 -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: 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> In-Reply-To: <4FE8BA77.9040901@php.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gm-Message-State: ALoCoQmXYCQB38fSQ3ipYZdGYE1GuJktE+YkR94OnBvzEJCqQXb9qlzOZ6u8O5Li+3KBlcOYlvpe Subject: Re: [PHP-DEV] [DRAFT] RFC - array_column() function From: aaron@aaronholmes.net (Aaron Holmes) 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 >