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

Re: easier duck typing in .can

Thread Previous | Thread Next
From:
Sam Vilain
Date:
June 17, 2006 23:09
Subject:
Re: easier duck typing in .can
Message ID:
4494EDC0.6020602@vilain.net
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() 
them?

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.

Sam.


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About