Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:64879 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 9662 invoked from network); 12 Jan 2013 06:59:20 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Jan 2013 06:59:20 -0000 Authentication-Results: pb1.pair.com smtp.mail=kris.craig@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=kris.craig@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.180 as permitted sender) X-PHP-List-Original-Sender: kris.craig@gmail.com X-Host-Fingerprint: 209.85.214.180 mail-ob0-f180.google.com Received: from [209.85.214.180] ([209.85.214.180:51713] helo=mail-ob0-f180.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E1/E1-28362-6C901F05 for ; Sat, 12 Jan 2013 01:59:19 -0500 Received: by mail-ob0-f180.google.com with SMTP id wd20so2414487obb.39 for ; Fri, 11 Jan 2013 22:59:16 -0800 (PST) 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=YJsg9h/Mmj2MgQCkCtzSxgbUo1wSgC+wrDLy3BKjNG4=; b=CmpApgMew3nVd02JMce1GpXD0FC9SngkzGSgjx5RL0d5g0TunKawZOByg4RDfKVRiM Uqt99B4xJU/8lmIlXQaNo3T61TfT+V+wFNWyvXvYgprfxTaxCBDR1Pi7c5RiWIN6Oq50 9sS1IuE/vpnbocnsg379uFElvIoQDxUXUvVI+FZUda+z79SPCqajh3KkVWecb3hYsSE5 zQn6HjzIF4opV7EijY1kOAlU/+48McDRwZj0mzux9RJGjUT7iapTAv2Kj0sLp/S9nunH 2e0ekxvFyFDM4Uneh3LWbUdHPW9XlH80wH3CvYo469hydueX4HhgRzqpA7GqqNDhKbub NrOw== MIME-Version: 1.0 Received: by 10.182.113.101 with SMTP id ix5mr18532025obb.73.1357973955912; Fri, 11 Jan 2013 22:59:15 -0800 (PST) Received: by 10.182.132.45 with HTTP; Fri, 11 Jan 2013 22:59:15 -0800 (PST) In-Reply-To: References: <50F0FB3B.2090509@sugarcrm.com> Date: Fri, 11 Jan 2013 22:59:15 -0800 Message-ID: To: Anthony Ferrara Cc: Stas Malyshev , Nikita Popov , PHP internals Content-Type: multipart/alternative; boundary=f46d0447f3dc41a48804d311f36b Subject: Re: [PHP-DEV] [VOTE] array_column() function From: kris.craig@gmail.com (Kris Craig) --f46d0447f3dc41a48804d311f36b Content-Type: text/plain; charset=ISO-8859-1 On Fri, Jan 11, 2013 at 10:53 PM, Anthony Ferrara wrote: > Stas, > > This is a great illustration of different visions we have here. On one > > hand, we have practical, immediate feature that covers a clear use case > > and does not add any constructs or complexity to the core language and > > services immediate need, covering several lines of frequently > > encountered boilerplate code with one function. > > > > On the other hand, we have a possibility to have in the future a > > fashionable syntax, which is a bit better, more concise and "cool > > looking" expression for what foreach already can do. > > > > So, my "vision", for example, is that while there's nothing wrong with > > "cool" language syntaxes and adding them, we should not reject simple > > practical solutions for them. This is what was done in PHP for years, > > and I think it is one of the reasons PHP is a great tool for the > > programmer. Just trying to make my "vision" more clear :) > > > > I definitely agree with you here. Voting against a library feature because > of a language future that's not even proposed yet is a bit... Odd... > > With that said, I'm inclined to vote against this, but for a different > reason. (Note I said inclined, I haven't voted yet because my mind isn't > made up yet completely)... > > I am concerned about library bloat. We already have 76 array functions: > http://us3.php.net/manual/en/ref.array.php > > IMHO, a new function should be added in one of three cases: > > 1. It's hard to do in user-land > > Meaning that it takes non-trivial code (30 to 40 lines, difficult error > handling, complex algorithms, etc). Considering that you can do the same > thing as this in 3 lines of user-land code without error handling, and 6 > with error handling, I don't think it qualifies. > > Contrast that to something like sort() which actually is a non-trivial > algorithm to do efficiently... > > 2. It's not performant to do in user-land. > > Some things are just plain more efficient to do in C than PHP. Something > like a quicksort. But in this case the trivial PHP implementation should > run in O(n), just as C does. And since C is doing hashtable access for > everything, I can't see that this is going to be significantly more > efficient in C (at least for common sizes of arrays, say less than 10k > elements). If there are benchmarks that prove this point wrong, I'll > gladly concede it... > > 3. It's extremely common. > > All other things aside, it would still belong in core IMHO if it's an > extremely common need. That way we can help common implementation problems > and make life easier. Pretty self explanatory. > > From what I can see this new function doesn't fit any of those three to a > significant enough extent. All three are definitely subjective, but I'm > leaning towards a no vote because I just don't feel there's enough > justification for the new function when weighted against the bloat > factor... > > My $0.02... Thoughts? > > Anthony > What do you believe is the biggest loss incurred by adding a function that is useful but does not fit any of the three criteria you listed? Personally, I can't really think of one. I think it's more important to focus on consistency between functions (arguments order, etc) and clear documentation (which could be more difficult with a ton of array-related functions to scroll through, but that could be mitigated by organizing them into alphabetized subgroups). --Kris --f46d0447f3dc41a48804d311f36b--