Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:62241 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 84327 invoked from network); 18 Aug 2012 13:52:28 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Aug 2012 13:52:28 -0000 Authentication-Results: pb1.pair.com header.from=packrat@nznet.gen.nz; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=packrat@nznet.gen.nz; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain nznet.gen.nz from 210.54.141.249 cause and error) X-PHP-List-Original-Sender: packrat@nznet.gen.nz X-Host-Fingerprint: 210.54.141.249 mta06.xtra.co.nz Received: from [210.54.141.249] ([210.54.141.249:36945] helo=mta03.xtra.co.nz) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 91/57-31572-81E9F205 for ; Sat, 18 Aug 2012 09:52:27 -0400 Received: from [127.0.0.1] (really [222.155.173.41]) by mta03.xtra.co.nz with ESMTP id <20120818135213.WUII22346.mta03.xtra.co.nz@[127.0.0.1]> for ; Sun, 19 Aug 2012 01:52:13 +1200 Message-ID: <502F9E02.1030704@nznet.gen.nz> Date: Sun, 19 Aug 2012 01:52:02 +1200 User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:14.0) Gecko/20120713 Thunderbird/14.0 MIME-Version: 1.0 To: internals Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: re: removing an item from an array From: packrat@nznet.gen.nz ("Morgan L. Owens") Rasmus Schultz wrote: > I disagree - this is (or should be) a simple, atomic operation... > yet, you've got a function-call, an intermediary variable, a boolean > test, and an unset statement repeating the name of the array you're > deleting from. > > This should be a simple statement or function/method-call, and in > most other languages it would be... How simple is it? Does it: 1) Remove one occurrence of the element (presumably the first) or all? 2) Reindex the array (as someone else argued was necessary to make it "properly indexed" afterwards) or not? 3) Modify the array in-place or return a modified array? 4) Use type-strict or normal comparisons? That's sixteen different interpretations of "remove a given value from an array" right there. Leave support for any of them out and someone is going to complain that they have to write a function to do what should be a "simple statement". Support all of them and there will probably _still_ be someone who wants their own particular set of circumstances catered for without having to write their own function to do it.