Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:62333 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 29512 invoked from network); 21 Aug 2012 03:49:09 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Aug 2012 03:49:09 -0000 Authentication-Results: pb1.pair.com header.from=tjerk.meesters@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=tjerk.meesters@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.160.170 as permitted sender) X-PHP-List-Original-Sender: tjerk.meesters@gmail.com X-Host-Fingerprint: 209.85.160.170 mail-gh0-f170.google.com Received: from [209.85.160.170] ([209.85.160.170:53126] helo=mail-gh0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 34/F7-28202-33503305 for ; Mon, 20 Aug 2012 23:49:07 -0400 Received: by ghbg24 with SMTP id g24so6152019ghb.29 for ; Mon, 20 Aug 2012 20:49:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=ltbmuo+s9fk1I5/x19LXjWgBnjMpNSk4ms56M+OZwSg=; b=a3xWezrbmEkPJ7BzRNR7jGa1Zt4uUPAsdYTb4L4TWnBYObLU3IYOr/p5cuazh3W+zY PIj1BmyKHOKgfTAwNGO1YWX3Odzq+wdl0eUQiYNE3QrRWEpTzEnQIOo8jXhIrzfoEOHj pq4kCH9o1S1ovk7GV3zlkg5k4EsBif0H8cXbVpSV+jGnbG7kUR2Vh1Ube+lF+isu4SIj IMo6c2OtvxAIGI6JITz5p9rV+Qnx3Wb3Z41mtJH6cUxuMO9G3ceIRYGJxIu7qOTfM7L2 pwcv9AUfFVUd1ACKs1XQOA4CRq3Rhkofkckxw4HkEHx4oz4A6AaVyTYY/0FD5VXM4Mmz iTKA== MIME-Version: 1.0 Received: by 10.50.158.195 with SMTP id ww3mr11937752igb.52.1345520943912; Mon, 20 Aug 2012 20:49:03 -0700 (PDT) Sender: tjerk.meesters@gmail.com Received: by 10.64.13.226 with HTTP; Mon, 20 Aug 2012 20:49:03 -0700 (PDT) In-Reply-To: References: <502EB667.1020602@lerdorf.com> Date: Tue, 21 Aug 2012 11:49:03 +0800 X-Google-Sender-Auth: XdompEU24j1YcB1gTPdnwy-goVc Message-ID: To: Rasmus Schultz Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary=14dae9340641e6556104c7be81dc Subject: Re: [PHP-DEV] re: removing an item from an array From: datibbaw@php.net (Tjerk Anne Meesters) --14dae9340641e6556104c7be81dc Content-Type: text/plain; charset=ISO-8859-1 On Tue, Aug 21, 2012 at 10:31 AM, Rasmus Schultz wrote: > Thank you, but this isn't really anything like what I had in mind. > > What I had in mind is more like set-semantics for arrays, e.g. designed to > work with sets of distinct values/objects. > > Since I do not have permission to write on the wiki, I posted an initial > draft here: > > https://gist.github.com/321ad9b4b8c4e1713488 Just an idea, since array_delete() may remove multiple values, I would change the return value to (int) and return how many elements were removed from the array. > > > > On Mon, Aug 20, 2012 at 10:10 PM, Yasuo Ohgaki wrote: > > > Hi, > > > > 2012/8/21 Rasmus Schultz : > > > I have a login (mindplay) but I do not have permission to post or edit > > > anything on the wiki... > > > > I've created RFC for this > > > > https://wiki.php.net/rfc/array_delete > > > > Get wiki account and finish discussion. > > I may write patch for this with my spare time, but > > it may take while to find time. I suggest write patch > > and send pull request. > > > > Regards, > > > > -- > > Yasuo Ohgaki > > yohgaki@ohgaki.net > > > > > > > > On Mon, Aug 20, 2012 at 8:01 PM, Will Fitch wrote: > > > > > >> Please let this die until someone is serious enough to come up with an > > >> rfc. This has been nothing but counterproductive arguing. If someone > > feels > > >> strongly about it, write an rfc then we can discuss? > > >> On Aug 20, 2012 7:53 PM, "Yasuo Ohgaki" wrote: > > >> > > >>> Hi, > > >>> > > >>> 2012/8/21 Herman Radtke : > > >>> >>> May be we should have something like > > >>> >> > > >>> >> >> > > >>> >> >> array_delete_if($array, function($v, $k=null) { if ($v == 300) > > >>> return > > >>> >> >> true; }) > > >>> >> > > > >>> >> > So array_filter? > > >>> >> > > >>> >> I'll use it or like for deleting, but the point of this thread is > > >>> >> "intuitive function for deleting element(s)" > > >>> >> > > >>> >> array_delete($array, $value|callable) > > >>> >> > > >>> >> would be nicer for users, perhaps. > > >>> > > > >>> > > > >>> > You are basically asking to alias array_filter with "array_delete". > > >>> That is > > >>> > a very slippery slope. I think array_filter is very a very obvious > > >>> choice to > > >>> > remove something from an array. The "filter" function/method is > > common > > >>> in > > >>> > functional languages (and functional frameworks like Underscore). > > >>> > > > >>> > These are things developers just need to learn as part of > > development. > > >>> > Really, this is entire thread should be on stack overflow, not > > >>> internals. > > >>> > > >>> I guess you haven't read later post. > > >>> > > >>> You've also made a novice mistake. > > >>> array_filter() DO NOT delete elements, but creates new array. > > >>> array_delete() is another form of array_walk(), not array_filter(). > > >>> See my posts. > > >>> > > >>> Having a API for dedicated task is good thing. > > >>> Who would argue array_pop()/array_push() isn't needed? > > >>> > > >>> Regards, > > >>> > > >>> -- > > >>> Yasuo Ohgaki > > >>> yohgaki@ohgaki.net > > >>> > > >>> -- > > >>> PHP Internals - PHP Runtime Development Mailing List > > >>> To unsubscribe, visit: http://www.php.net/unsub.php > > >>> > > >>> > > > -- -- Tjerk --14dae9340641e6556104c7be81dc--