John Peacock wrote:
You have a very narrow, and I might say a little bizarre,
interpretation of how Perl objects stringify.
You are not overloading the object, you are overloading the reference.
If you were overloading the deref of the reference then I wouldn't have
a problem with this. But I really don't like the idea of a reference
having difference behaviors based on the kind of object that it is
referencing. If there was a different class for the reference itself
(i.e., thrRef) then I wouldn't have a problem either but since all
references in Perl are to the same "type", I don't think that changing
the behavior based on the deref is correct.
What you propose is actually a change to the way that references
behave and not the way that your class behaves. That is, you want
the behavior of a reference in certain types of expressions be
different depending on the class of object that it references.
Yes, overloading allows me, as a class author, full freedom to decide
how my object will behave in different situations. It has nothing
whatsoever to do with the behavior of well-behaved introspection tools:
No, you are changing the way the reference to the class behaves. I have
no problem with you changing the class itself.
What code do you have that can't handle this? Or are you just arguing
the theoretical case?
It is mostly that I don't want the interactive debugger behavior to
change. I use this almost daily. This is particularly useful when
viewing a reference to a class with several derived classes. WIth the
current behavior you can see immediately which sub-class the reference
"points" to.
- Jim