On 12/6/02 4:41 PM, Michael Lazzaro wrote:
>  my PersonName $name = .new(...);
>  my FormalStr   $s = $name;    # "Dr. William P. Smith"
>  my InformalStr $s = $name;    # "Bill"
> 
> Whether that is good, bad, or indifferent I leave to the OO Police.

I'm not even deputized, but I call foul: excessive use of subclassing ;)

Even in Perl 5 code, I end up having multiple stringification methods for
things like error messages.  But I simply use different method names for
each (e.g. error() and public_error()), and don't bother with overloading ""
at all.

I think the desire to have stringification DWIM is now bordering on RMMP
("read my mind, please" :)  Yes, there will probably be many WTDI in Perl 6,
but I doubt any will end up beating the simplicity and clarity of named
methods.

Standardizing these methods names in an effort to help out debuggers seems
reasonable, but I wouldn't go much further than that.  In fact, I'd go so
far as to say that the default stringification of most objects should
probably still be something like FOO(0x1234), since I frequently use those
strings to find out if two things are pointing to the same object.  At the
very least, some sort of similar "unique identifier" should be accessible to
any stringification method writer...

-John

Reply via email to