On 17.07.2012, at 21:03, Stas Malyshev wrote:

> Hi!
> 
>> This idea has been proposed many times in the past and it is actually
>> a very good proposal, for array, string or other types.
> 
> If we have "$array->foo()", we should also have "class foo extends
> array" which allows to override foo() in array. This will require some
> serious changes, which need to be RFCed and reviewed and seen if they
> can really fit the language properly. Just saying "let's bolt on method
> calls on top of arrays" is definitely not very good. Having OO Array
> type may be good, if we will be able to figure out suitable design that
> will allow the same flexibility and power as regular arrays - though I'm
> not sure how to do it now.
> 
>> The only reason why it is not yet implemented is the technical
>> complexity to do it. We need pseudo objects and the likes, and it is
>> really not something easy to do, in an efficient enough way.
> 
> I disagree - I do not think we need pseudo-objects. If the only point of
> the exercise is to convert a call of array_pop to $array->pop, it's not
> worth it. It'd just make the language more messy - you wouldn't know
> what -> means anymore.

+1

I am for making array a proper class with methods.

"Legacy" functions can be implemented as wrappers around it:

    function array_push(&$array, $value)
    {
        $array->push($value);
    }

There is absolutely no sense in creating new "pseudo object" entity. It would 
just add tons of confusion.

p.s. in case of array, we already have http://docs.php.net/ArrayObject which is 
a good starting point

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

Reply via email to