Re: String extension proposal

From: Date: Thu, 12 Jun 2008 08:04:59 +0000
Subject: Re: String extension proposal
References: 1 2  Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-5511@lists.php.net to get a copy of this message
Hi Francois, Can you send me on that link to the RFC wiki? Also I agree it would get confusing having two types of string. Wouldn't implementing Iterator allow one to do a foreach on the Array object? Is there any way I can help out with this? Regards, Mark On Wed, Jun 11, 2008 at 11:49 PM, Francois Laupretre <flconseil@yahoo.fr> wrote: > The only thing I am sure about OO strings/arrays is that we cannot have > separate 'native' strings and 'object' strings, even if it is easier to > implement (and __tostring() cannot work for arrays). It also would probably > have a significant impact on performances. > > The idea I want to investigate is a wrapper to allow method calls on native > types. Each method would call the corresponding function. If it works, the > next step will be to use return_value_used to modify variables in place if > the result is not used. Then, there will be some other points to consider, > as the possibility to extend these classes, reflection, calling methods on > immediate values,... > > Joe : I don't understand why you talk about BC breaks, as the approach I am > taking does not break any BC, it is just an extension to the current syntax. > Or did I miss something ? > > I have also started an RFC detailing the methods, type by type. When it is > ready, I'll try to publish it on the RFC wiki. > > Regards > > François > >> De : Mark Frawley [mailto:markfrawley@gmail.com] >> >> The more I think about it the more I like Francois' idea. The idea of >> making them separate is appealing only because it is more realistic. >> I really do believe it is a really good direction for PHP. I haven't >> heard a good argument against it. >> Could someone who is in a decision making capacity find the time to >> address this request? I know it might be tedious to revisit it, >> but it does seem I'm not the only programmer looking for this feature. >> >> Regards, >> Mark >> >> On Tue, Jun 10, 2008 at 9:38 PM, Francois Laupretre >> <flconseil@yahoo.fr> wrote: >> >> De : Joe Stump [mailto:joe@joestump.net] >> >> >> >> as a smart man once said, "I disapprove of what you say >> >> (code), but I will defend to the death your right to say (code) it." ;) >> > >> > +1 >> > >> >> I for one would love a unified OO interface for both strings and >> >> arrays as I find them to be more concise. A good example of what I'm >> >> looking for would be: >> >> >> >> $arr = new array('foo'); >> >> $foo = $arr->pop(); >> > >> > Defining String & Array classes is interesting but it would be >> much better >> > if these objects could remain compatible with native strings and arrays. >> > >> > Combining this with a smart use of return_value_used, it would give >> > something like : >> > >> > $arr=array(' FOO ','bar'); >> > >> > $a2=$arr->reverse(); // $arr is not modified, The reversed array is >> > returned. >> > >> > $arr->reverse(); // $arr is reversed in place >> > >> > $s=$arr->pop(); // returns ' FOO ' >> > >> > $s2=$s->trim()->tolower(); // returns 'foo' >> > >> > $s->trim(); // $s becomes 'FOO' >> > >> > I know it cannot be done as an extension to the current core >> and implies a >> > mechanism allowing to consider native types as objects (at least to call >> > methods). >> > >> > Please don't reply that it's too complex ot that I'd rather use >> > python/java/cobol(just kidding)... >> > >> > Regards >> > >> > Francois >> > >> > >> >> -- >> PECL development discussion Mailing List (http://pecl.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php >> >> > >

« previous php.pecl.dev (#5511) next »