On Friday 02 March 2007 00:53, demerphq wrote:

*snip good discussion*

> Now if there was an ->implements() utility function as well as the
> ->isa() funcation, then I think IO::Handle would contrive to ensure
> that IO::String->new(\$string)->implements('IO::Handle') would return
> true even though IO::String->new(\$string)->isa('IO::Handle') would
> not. (Im not sure if this is the same as chromatics proposed 'does'
> function).

Yes, that's one of the main motivations for roles.  It's in 5.9.4 as 
UNIVERSAL::DOES().

For the curious who want to do further research, C++ supports structural 
typing, while Perl's type system is, at least for objects, mostly nominal.

The logical approach to a nominal type system appears to lead to allomorphism.

For more detail, see:

http://www.oreillynet.com/onlamp/blog/2006/08/roles_composable_units_of_obje.html

-- c

Reply via email to