Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:62289 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 44954 invoked from network); 20 Aug 2012 15:35:05 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Aug 2012 15:35:05 -0000 Authentication-Results: pb1.pair.com smtp.mail=rasmus@mindplay.dk; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=rasmus@mindplay.dk; sender-id=unknown Received-SPF: error (pb1.pair.com: domain mindplay.dk from 209.85.212.42 cause and error) X-PHP-List-Original-Sender: rasmus@mindplay.dk X-Host-Fingerprint: 209.85.212.42 mail-vb0-f42.google.com Received: from [209.85.212.42] ([209.85.212.42:51853] helo=mail-vb0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id EB/2F-07742-72952305 for ; Mon, 20 Aug 2012 11:35:05 -0400 Received: by vbbfs19 with SMTP id fs19so6193324vbb.29 for ; Mon, 20 Aug 2012 08:35:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:x-gm-message-state; bh=Hxvle62zJEQ2hN2XR3VfGNOgeCp9Y9HcONCO/NK9ia0=; b=IX9PitT/Hg1AAPBUAz3WSSdyQ8h8A6npFcoGCdWhz1XzlugWbUy7wpHdPNr+FtzQH8 8/laCdN2ni9Gp0EuOn+ucNFo8MdGVc/tfRqXZJH2qMFze2qf3cmIWrkkvQwTwp5/DP7W ST7tRvjFQCi2zw/OwKCHjlS06fzkT6ddPpfU6k1xefOLCjKB2+D6FCQFbwpSys87ckMc hZtxaGFVcfheYSlNRwfdgV6ctAFoJJTN/gWKU5rq1J2KUiE5SNH8QsNeSfLAzLvpi8c2 98GvDSLaKJ0PuxnqhOoDyjUbu7f5ERWA8WjKkFxn23zH2xjsYpsZtCrPv4UwilaeGzYS p22Q== MIME-Version: 1.0 Received: by 10.58.68.4 with SMTP id r4mr11644954vet.21.1345476900446; Mon, 20 Aug 2012 08:35:00 -0700 (PDT) Received: by 10.220.24.3 with HTTP; Mon, 20 Aug 2012 08:35:00 -0700 (PDT) In-Reply-To: <96A1E46F-8347-4B29-8277-AEC122063869@gmail.com> References: <96A1E46F-8347-4B29-8277-AEC122063869@gmail.com> Date: Mon, 20 Aug 2012 11:35:00 -0400 Message-ID: To: internals@lists.php.net Content-Type: multipart/alternative; boundary=047d7b2e4b2cb4619304c7b4405f X-Gm-Message-State: ALoCoQnDXLzAPizKZsKqgZgOWflgOe8QGbOe2lqoC2gcno8hgIRHp6VDJf54lKCKCw1SknrByjed Subject: Re: [PHP-DEV] removing an item from an array From: rasmus@mindplay.dk (Rasmus Schultz) --047d7b2e4b2cb4619304c7b4405f Content-Type: text/plain; charset=ISO-8859-1 I think adding more collection-types is the intuitive reaction to this issue, but there's something to be said for the idea of having only a single collection-type - I think that's one PHP feature we should not give up. Not having to pick and choose (and compromise) to select the "right" collection-type, and not having to refactor when you realize you needed another collection-type - as well as easy comprehension for developers... these are valuable aspects of having only a single collection-type. Some newer languages like Opa embrace that idea with great elegance. Giving up on that idea should be the last option, in my opinion. There are plenty of cases for collections of objects that do not have a scalar key, where the key is indeterminate, or where the key can change - and thus cannot have known indexes. As an aside note, I recently benchmarked array_search() for a project that needs to store many different types of objects in a list - and searching a list with 1000 objects for one specific object is extremely fast: a couple of micro-seconds more (per search) when compared against a hash-based lookup with a known key, so (in my case) nothing to worry about at all in terms of performance. Arrays are a powerful and pure feature in PHP - I would vote against introducing more collection-types, and instead leverage the already powerful and well-understood existing singular collection-type. On Sat, Aug 18, 2012 at 2:42 AM, Alexey Zakhlestin wrote: > > On 16.08.2012, at 0:18, Rasmus Schultz wrote: > > > How come there is no straight-foward obvious way to simply remove a given > > value from an array? > > Well, this sounds like a reason for creating SplSet class > > --047d7b2e4b2cb4619304c7b4405f--