Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:45144 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 78603 invoked from network); 30 Jul 2009 14:50:46 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Jul 2009 14:50:46 -0000 Authentication-Results: pb1.pair.com header.from=guilhermeblanco@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=guilhermeblanco@gmail.com; spf=pass; sender-id=pass 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:56996] helo=mail-qy0-f203.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 86/EF-03589-143B17A4 for ; Thu, 30 Jul 2009 10:50:42 -0400 Received: by qyk41 with SMTP id 41so1961358qyk.29 for ; Thu, 30 Jul 2009 07:50:38 -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=AcsHCQC1Fdu/FrsigaaWNUeP6en11jXo/XHReyXEPNY=; b=SjSETWuy9HSlqajXfRBWIBDe4QWCYYeKcV7a7oeY/L3Dpq3OpgCLdMyYjCHnQIR5v/ T/bVw+zcCyai2JMlZtlPjUHPKVyD/DUwrnHX83fFQGWHpvXt6gkCd7MLL2X317clyRm9 nO0v2101Dl2ZMsz3QN3tHdxU0V5T5Ct/V2J08= 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=hnEcJAUvqyg6iw7ovZ12Xr/1TcP0Y2U9cZlXsyAV6vjOz3G1tKg/gvcn2MHmf7OZXb nj4sRW7E2fPjxKUM9NKvrrehaYT8TYZYqWn0FNsBFjV5mDgOPqr2XVUEtQMbb5VQL/sV 3WlR4QQzUShRxSUwXZ9wwI5qYdt61Yfdnnmb8= MIME-Version: 1.0 Received: by 10.220.75.148 with SMTP id y20mr1406719vcj.100.1248964965086; Thu, 30 Jul 2009 07:42:45 -0700 (PDT) In-Reply-To: References: <1248962475.4159.14.camel@goldfinger.johannes.nop> Date: Thu, 30 Jul 2009 11:42:44 -0300 Message-ID: To: Alexey Zakhlestin Cc: =?UTF-8?Q?Johannes_Schl=C3=BCter?= , 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) I'm trying to avoid a "globally solution" on first instance to avoid a great impact on language. If you wanna ask me what's the global solution, I'll suggest a Collection like implementation for all array functions. http://en.wikipedia.org/wiki/Collection_%28computing%29 http://trac.doctrine-project.org/browser/trunk/lib/Doctrine/Common/Collecti= ons Since it's a too much impactable code, I prefer to go straight at the first glance to support basic operations, treating ArrayObjects as normal arrays. This would lead to a simpler implementation. So, here are the answers of your questions: > - is that specific to ArrayObject or do we "need" interfaces like "Sortab= le" or "Shuffable" All Interfaces that can be treated as normal arrays (implements ArrayObject) should be supported. Why not ArrayAccess on first stage? I do not consider it right now because it'll require the method getArrayCopy() to be moved from ArrayObject to ArrayAccess. > - What should stuff like array_merge(ArrayObject, array) do It should return an array, just like the current function prototype defines > - Should we do this globally? (should ldap_set_option() allow an ArrayObj= ect as 3rd param?) This can be obviously be considered... but at the first step, let's be strict to the plan an only support array operations. Basically what would be the approach I'm looking for? For all array_* functions, inspect if given parameter is an array or an instance of ArrayObject. If instance of ArrayObject, call ArrayObject::getArrayCopy() and proceed normally with execution of each array_* function. It can't be that hard! =3D) Cheers, 2009/7/30 Alexey Zakhlestin : > 2009/7/30 Johannes Schl=C3=BCter : >> On Thu, 2009-07-30 at 00:08 -0300, Guilherme Blanco wrote: >>> What do you think about the possibility to support ArrayObject >>> instances in array_* functions? >>> If you all agreed on this, I can definately help to complete the >>> patch, but I need some initial guidance to finish at least the first >>> function. >> >> In general I'm for bringing Iterators/ArrayObject/.. on a line with >> arrays but please don't simply patch some functions but let's try to >> find a as consistent as possible global solution. >> >> Questions included there are of these kinds (just examples) >> - is that specific to ArrayObject or do we "need" interfaces like >> =C2=A0"Sortable" or "Shuffable" >> - What should stuff like aray_merge(ArrayObject, array) do >> - Should we do this globally? (should ldap_set_option() >> =C2=A0allow an ArrayObject as 3rd param?) >> >> Especially the latter shows that a proper solution might be not to patch >> individual functions but to introduce some form of abstraction from >> HashTables for "array operations" and then use that interface. >> >> Simply extending a few functions will end in a mess but looking around >> people seem to love these structures so improving them is good. > > agreed. > the proper solution would be to define several interfaces, make > functions accept objects of these interfaces and then add some > "hacks", which would pretend, that array() implements these. > > -- > Alexey Zakhlestin > http://www.milkfarmsoft.com/ > Sent from St Petersburg, Russian Federation > --=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