On Fri, Jan 18, 2008 at 09:16:39AM -0800, Larry Wall wrote:
: Though it's not quite the same, since the prefix presumably forces
: a multiple dispatch to Perl's idea of notiness, while a direct .not
: method would rely on the the object's notion of notiness.  This is
: probably a good distinction for cross-language programming.
: 
: So I think Object should define a default .not that is defined in
: terms of .true.  If a Perl class wants to override that, it's
: probably because it has a more efficient .not test, and wants to
: define .true in terms of .not instead.

It occurs to me that a foreign object might not *have* a .not method,
especially if it's not a boolean type.  So I think if the foreign
language dispatch fails, it should try to redispatch to any ancestors
it thinks it has in Perl space, Object if nothing else.  That would
at least allow an attempt at mapping .not to !.true.  But maybe
that means that Object's definition of .not should be !true($obj) to
give P6 multis a shot at defining truth for the foreign object before
calling into the (probably non-existent) .true method on the foreign
object.  I figure if it's not a boolean type, it probably won't have
either .not or .true, and P6's prefix:<true> for that type probably
needs to compare the value to 0 or "" or some such.  Or maybe Object's
definition of truth can be sophisticated enough to notice foreign
influences and compensate for them.  Seems like something MD would
be good at though.

All that being said, we want boolean tests to be *fast*, so since
prefix:<?> et al. have proto definitions, we probably can do some
decent inlining in lexical scopes where the set of truth multis is
known at compile time.

Larry

Reply via email to