In "[perl #60350] [TODO] default __get_string method", Patrick added a default Object.Str() that classes can override to get custom stringification. Formerly, you could do that only by defining a method named __get_string().

Currently, you can overload number context by creating a __get_number () method and boolean context via __get_bool(). Should there be an analogous Num() and Bool() method on Object? Would it Num() return 0 by default? And a default Bool() that returns True? The Failure class would override negatively, and the container classes could override Num()

Is this making life harder by making two methods to override, Str() and __get_string, Num() and __get_number(), Bool() and __get_bool()? Maybe instead Str(), Bool(), Num() should be magic and automatically get a :vtable tag via actions.pm? Then maybe we could drop the __get_* counterparts?

I'd be happy to implement if someone would comment on the best approach.

Chris

Reply via email to