Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:45155 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 32732 invoked from network); 30 Jul 2009 19:06:11 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Jul 2009 19:06:11 -0000 Authentication-Results: pb1.pair.com smtp.mail=guilhermeblanco@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=guilhermeblanco@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.221.203 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: guilhermeblanco@gmail.com X-Host-Fingerprint: 209.85.221.203 mail-qy0-f203.google.com Received: from [209.85.221.203] ([209.85.221.203:43681] helo=mail-qy0-f203.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6E/A8-25953-12FE17A4 for ; Thu, 30 Jul 2009 15:06:10 -0400 Received: by qyk41 with SMTP id 41so2203282qyk.29 for ; Thu, 30 Jul 2009 12:06:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=UgmoRkM6jGzU3Q54HURgtRKXGnis9+H+mwx1kiMSGAU=; b=Or6Bu1lqnZbdLma1D8qLfrEDEifUvUCWVrOW/MBb7wDNSD06N2gkNuUcmyu6zjEdcq OUkpdbM+ukvchhlF31JNiQYyoLPMCgm3613r7ymiPL0mFS0gvHhi6GfJ/MgNK4oP2qpv NBwvGgSF50X28fWhUT4JfCkCfPckU0WQiotI4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=PiuXMLRJiSyAvaiXlWVgybGVPRLhfZ6REAg8qGApNNI5P31Tnjr98ZLS+Y/sC4l9+a bWVdWnkbY94A1gwjCDyIIbRZ0fdTo4c1RgGpcre/gsUBk+QW0p/5q7hMj1rVw8QJHfPz EHubUlzkXZa9HpRJfyqkv2GP1HiZoHwvynYzU= MIME-Version: 1.0 Received: by 10.220.95.206 with SMTP id e14mr1941718vcn.34.1248980766992; Thu, 30 Jul 2009 12:06:06 -0700 (PDT) In-Reply-To: <4A71E4DD.2090005@zend.com> References: <1248962475.4159.14.camel@goldfinger.johannes.nop> <1248968847.4159.31.camel@goldfinger.johannes.nop> <4A71E4DD.2090005@zend.com> Date: Thu, 30 Jul 2009 16:06:06 -0300 Message-ID: To: Stanislav Malyshev Cc: =?UTF-8?Q?Johannes_Schl=C3=BCter?= , Alexey Zakhlestin , PHP internals Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Supporting ArrayObject in array_* functions From: guilhermeblanco@gmail.com (Guilherme Blanco) Hi Stan, I don't really know which implementation is preferrable. I just dropped the idea here first. Once decided, I can write a detailed RF= C. With some initial help, I can work on the patch to support it. I'm not expert in internals, so some help will be surely needed. I'm totally opened to suggestions. If chosen the approach 2, I'd like to consider naming that Roman said: SplCollection and SplArray. We can also merge with your idea to split into small subsets.... but surely the array OO native implementation (Collection, SplArray, etc) must implement all of them. So... what do I need to do to move this idea forward? Open a poll about which approach should be considered for RFC? Cheers, On Thu, Jul 30, 2009 at 3:22 PM, Stanislav Malyshev wrote: > Hi! > >> 1- A class that implements ArrayAccess must be useable everywhere an >> "array" is useable; > > The problem is that many functions dealing with arrays do not make sense > with generic object. For others, it may make sense in theory, but not be > practical - e.g., suppose you have ArrayAccess object referring to a > database field, how easy would be to make shuffle() work on it? How > practical would it be? > >> 2- ArrayAccess needs to be expanded with methods for all the array >> functions and ArrayObject needs to implement them; > > All 70+ of them? That'd be one fat interface. > >> How would it be achieved? >> $coll->sort(); instead of sort($coll); >> $coll2 =3D $coll->reverse(); instead of $coll2 =3D array_reverse($coll); > > Note that this also eats up a lot of useful names, and makes you implemen= t > functions that you would never use, such as picking a random element or > finding difference between arrays. > > I think all array operations should be divided into following classes: > 1. Basic ones, probably ArrayAccess/Iterator interface should be enough > 2. Compound ones implemented on top of basic ones (i.e. array_sum is a > combination of iteration and +, etc.) > 3. Additional operations non-reducible to (1), like shift/unsift or exoti= c > ones like array_change_key_case(). > > First two classes are easy to handle, the last one should be handled > separately on per-case basis. > -- > Stanislav Malyshev, Zend Software Architect > stas@zend.com =C2=A0 http://www.zend.com/ > (408)253-8829 =C2=A0 MSN: stas@zend.com > --=20 Guilherme Blanco - Web Developer CBC - Certified Bindows Consultant Cell Phone: +55 (16) 9215-8480 MSN: guilhermeblanco@hotmail.com URL: http://blog.bisna.com S=C3=A3o Paulo - SP/Brazil