Perl has this (it's called "stratification"), and it is quite useful.
One example is that you have an error object that contains various
properties (line location, error class, error level, error code, etc).
And on evaluating the object as a string, it dumps it as an easy to read
error message.

-Jason



On Fri, 2002-08-16 at 08:52, Brad LaFountain wrote:
> I want to throw together a quick hack so that objects can implement a
> __as_string() method that will get called when the string is used in a string
> contex. Instead of append "Object".
> 
> $s = (string)$object;
>      or
> $s .= $object;
> 
> also the same things with arrays that will do something similar to
> $s = implode(" ", $array);
> 
> $s = (string)$array;
> $s = $array . "\n";
> 
> Before anyone jumps on this and says no way cause it easy to implemnt your own
> __to_string() and call it when you want it or what is wrong with implode(" ",
> $array). Think of exactly how usefull is appending the word "Array" or
> "Object".
> 
>  Thoughts?
> 
>  - brad
> 
> __________________________________________________
> Do You Yahoo!?
> HotJobs - Search Thousands of New Jobs
> http://www.hotjobs.com
> 
> -- 
> PHP Development Mailing List <http://www.php.net/>
> To unsubscribe, visit: http://www.php.net/unsub.php
> 



-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to