On Thu, Nov 06, 2008 at 01:22:24AM -0600, Chris Dolan wrote:
> 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()

Much of this (including the Str() method) is described in Synopsis 13
and other places, so we'll simply follow the spec.  There is still
a bit of vagueness about .Bool versus .true, so we probably
need some clarification there.

> 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?

No.  First, the vtable functions only need to exist in the base 
Object (Perl6Object) class -- everywhere else we use/overload the
Perl 6 named method.  The vtable functions in Object simply 
re-dispatch to the appropriate methods, and thus never need to
be overridden again (unless needed for some internal Parrot reasons).

Second, it's possible (even likely) that in some programs the 
methods Bool(), Num(), etc.  return things that aren't Parrot's
int, num, or string.  At present vtable functions constrain us 
to returning only int, num, or string values (that can't have any
properties or methods), so I think we need to keep the potential
separation.

Thanks,

Pm

Reply via email to