Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:60963 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 7473 invoked from network); 25 Jun 2012 19:22:38 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Jun 2012 19:22:38 -0000 Authentication-Results: pb1.pair.com smtp.mail=ben@benramsey.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=ben@benramsey.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain benramsey.com from 209.85.161.170 cause and error) X-PHP-List-Original-Sender: ben@benramsey.com X-Host-Fingerprint: 209.85.161.170 mail-gg0-f170.google.com Received: from [209.85.161.170] ([209.85.161.170:38598] helo=mail-gg0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 04/57-56161-D7AB8EF4 for ; Mon, 25 Jun 2012 15:22:38 -0400 Received: by ggnf2 with SMTP id f2so3670135ggn.29 for ; Mon, 25 Jun 2012 12:22:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding :x-gm-message-state; bh=ZFRmurDMfYvnZXvdfrDJztiittbUPTaxwJyM0kOkvvY=; b=OdI9L9kYJ/opvNDGNGKp9Q5ZmbZzs9T/2WdphSkzJd4itjECBsL8LwjFLkRjbww2Pc c0VPyt4GOCLzMGGRmS2N39jRhFFpqyS+gvIEI4jODR4KRZr7Hu6DKhk9EdNqbcEKSVHw sfU5WtF4Q87kAV5T5KIF26woM/gm/CG/rP1soyGiYm86EcKkRpQ++IZlDRoXAf8UH4Cm ZDT8lfi6/iUo5/qn2GhbCV4LsoDHUKYIYlUVCt58ty9lV3SkG0+q3w4ckXUoFfIo0lAQ 4L0aKWcSZyjH5VhkJCDtTHUaButBc5EtzYJsp5MOLiqp1bbvgAxOcA/7CBj4fR1emJDn kLLw== Received: by 10.236.74.74 with SMTP id w50mr14643472yhd.34.1340652153912; Mon, 25 Jun 2012 12:22:33 -0700 (PDT) Received: from earendil.local (w194.z064002187.mco-fl.dsl.cnc.net. [64.2.187.194]) by mx.google.com with ESMTPS id n15sm48866794anh.6.2012.06.25.12.22.32 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 25 Jun 2012 12:22:32 -0700 (PDT) Sender: Ben Ramsey Message-ID: <4FE8BA77.9040901@php.net> Date: Mon, 25 Jun 2012 14:22:31 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:13.0) Gecko/20120614 Thunderbird/13.0.1 MIME-Version: 1.0 To: Matthew Weier O'Phinney 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> In-Reply-To: <3D.D4.56161.13978EF4@pb1.pair.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gm-Message-State: ALoCoQnT65Yb8YnsJNlV14+dET6YgSQJCD2UVr4aBuH9graoeKyXSjblgv2va4xSQV8US09touZH Subject: Re: [PHP-DEV] [DRAFT] RFC - array_column() function From: ramsey@php.net (Ben Ramsey) 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