develooper Front page | perl.perl6.language | Postings from June 2006

Re: easier duck typing in .can

Thread Previous | Thread Next
Sam Vilain
June 17, 2006 23:09
Re: easier duck typing in .can
Message ID:
Yuval Kogman wrote:
> Since CANDO is a multimethod, IMHO this can be safely extended to
> allow:
> 	$object.can(Class);
> 	$object.can(Role);
> to better support duck typing.

Why would you not use .does or .isa there?  Are you wanting this to go 
through all of the Class/Role's methods and check that the $object.can() 

I think that perhaps .can($Method) (where $Method.isa(Meta::Method)) 
would be acceptable, then .can(Role) can either be defined to be 
.can(all(Role.get_methods)), or we just leave the user to use that 
snippet - after all, such extreme duck typing is expensive and shouldn't 
be  huffmanised overly IMHO.  We want people to use the Role objects 
unless they have a really good reason, and besides you can always just 
wrap things up in a Facade if you have to.


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About