Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:64878 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 8082 invoked from network); 12 Jan 2013 06:53:26 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Jan 2013 06:53:26 -0000 Authentication-Results: pb1.pair.com header.from=ircmaxell@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ircmaxell@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.52 as permitted sender) X-PHP-List-Original-Sender: ircmaxell@gmail.com X-Host-Fingerprint: 209.85.212.52 mail-vb0-f52.google.com Received: from [209.85.212.52] ([209.85.212.52:56317] helo=mail-vb0-f52.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E0/91-28362-46801F05 for ; Sat, 12 Jan 2013 01:53:24 -0500 Received: by mail-vb0-f52.google.com with SMTP id ez10so2108149vbb.39 for ; Fri, 11 Jan 2013 22:53:22 -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=rQekcMlyb9aQd/z3tAzJslgn0kIH6Oes96FiLy6QfQM=; b=deeND22hl/7gy9bwX6hKLUEob5TIrPpAl8JrCY5XxyAXcwWP8IBTIfiavuLS8YP6pT E4uDXh6Bn4JDuS5jNsJHFAwk8NIY21toCIXtIv2Mw7lpY8xtRxwsjZQVE2mIu7NLnLMO NGW99cLqstAaI4+M+CxNDuBf7C4amINIhroJZtmnnzhiCMXpXRVjt7ktf3JsB8eSwu7z jn+2JcygzJhLr/+KHeNUl2SVU6QLzgihWA8Ry0t4cDonqURvxBVdE+wKy+ublbJd7mYp yvV//GKUMmHMzVT8HAA5OhgyOX+OmHuTaKDevgBQjuk5ulpea2qliPHNZPAxR8m31kaz FIPg== MIME-Version: 1.0 Received: by 10.58.234.234 with SMTP id uh10mr8676937vec.37.1357973601947; Fri, 11 Jan 2013 22:53:21 -0800 (PST) Received: by 10.58.173.4 with HTTP; Fri, 11 Jan 2013 22:53:21 -0800 (PST) In-Reply-To: <50F0FB3B.2090509@sugarcrm.com> References: <50F0FB3B.2090509@sugarcrm.com> Date: Sat, 12 Jan 2013 01:53:21 -0500 Message-ID: To: Stas Malyshev Cc: Nikita Popov , PHP internals Content-Type: multipart/alternative; boundary=047d7b6d96fc288e8404d311de6b Subject: Re: [PHP-DEV] [VOTE] array_column() function From: ircmaxell@gmail.com (Anthony Ferrara) --047d7b6d96fc288e8404d311de6b Content-Type: text/plain; charset=ISO-8859-1 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 --047d7b6d96fc288e8404d311de6b--