Re[2]: [PHP-DEV] Re: hook cast_object handler in userspace
| From: | (Marcus B�rger) | Date: | Wed, 06 Aug 2003 18:23:00 +0000 |
| Subject: | Re[2]: [PHP-DEV] Re: hook cast_object handler in userspace | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-3789@lists.php.net to get a copy of this message | ||
Hello Cristiano,
Wednesday, August 6, 2003, 3:19:34 PM, you wrote:
CD> Simeon Koptelov wrote:
>> Hello Cristiano,
>>
>> Here's why i think that interface is not good solution.
>>
>> We need the toString method like java's one to
>> safely assume that _every_ object has the string representation. This
>> means we can say $obj1->toString() and $obj2->toString() and don't
>> care if $obj1 and $obj2 do support this method. In fact we _already_
>> have this functionality in ( string )$obj cast -- it's
>> applicable to any object, doesn't it?. All we need is to formalize
>> this cast in OOP manner. Interface is only the way to describe what class
>> can do. If every class can provide it's string representation why should you
>> implement some interface?
>>
>> It's only my $.20 though.
>>
CD> Maybe you're right.
CD> I can move the code away from the "cast" function and create a toString
CD> method on the "Object" class wich returns "Object id #n".
CD> Let's see what the others think about it...
Very bad idea, this is used as introspection and veryfication and ashouldn't
be changed.
--
Best regards,
Marcus mailto:helly@php.net