Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:60965 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 20741 invoked from network); 26 Jun 2012 00:35:18 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Jun 2012 00:35:18 -0000 Authentication-Results: pb1.pair.com smtp.mail=dragoonis@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=dragoonis@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.160.170 as permitted sender) X-PHP-List-Original-Sender: dragoonis@gmail.com X-Host-Fingerprint: 209.85.160.170 mail-gh0-f170.google.com Received: from [209.85.160.170] ([209.85.160.170:47092] helo=mail-gh0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CF/D9-56161-4C309EF4 for ; Mon, 25 Jun 2012 20:35:16 -0400 Received: by ghbg2 with SMTP id g2so3927349ghb.29 for ; Mon, 25 Jun 2012 17:35:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=WyVN7VjJ3Dg0Y9++tSe4mF3CGqdbot+nyC9KDD0g5PI=; b=mIfu6514j6RplpkS4exiFi5oAIzbV9DNJniNhrB7oW860OmC6+PU4vc2nTPiPHRC3t OAZdHoo5+h2jyRVAx9ODxGZrScFw57K+/bCNYl7H5f9rEFq8gWjh6B6Z4kO8RpTDuGLs hCNDiT2y8RjWAJmalZAigqQZXu9U37IqYYKxw4hTmQKvnwQYnGQkapyuaHazYbaN3WcR lVflWmyg/Yhs8piQdCcR0//0Ads49pHUgiAoCAIx252rzANjeBo/5PxvcHFkX3oi6odZ Skloj9fi6bEvKwpISA/W78kkTQJDoWnZqwNay41DEbH3TwxRE21YA/Z/QKNyY9WpHDR7 KATQ== MIME-Version: 1.0 Received: by 10.50.217.199 with SMTP id pa7mr9641528igc.17.1340670912768; Mon, 25 Jun 2012 17:35:12 -0700 (PDT) Received: by 10.64.32.72 with HTTP; Mon, 25 Jun 2012 17:35:12 -0700 (PDT) In-Reply-To: <4FE8CAAD.3030002@aaronholmes.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> Date: Tue, 26 Jun 2012 01:35:12 +0100 Message-ID: To: Aaron Holmes Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary=14dae9341101842a7a04c35545be Subject: Re: [PHP-DEV] [DRAFT] RFC - array_column() function From: dragoonis@gmail.com (Paul Dragoonis) --14dae9341101842a7a04c35545be Content-Type: text/plain; charset=ISO-8859-1 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/**a382d60f6abc94b6a965525872f858* >> *e48abc00de >> >> 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 > > --14dae9341101842a7a04c35545be--