develooper Front page | perl.perl6.language | Postings from January 2004

RE: A modest question

Thread Previous
From:
chromatic
Date:
January 8, 2004 23:31
Subject:
RE: A modest question
Message ID:
1073632961.1287.65.camel@localhost
On Thu, 2004-01-08 at 16:24, Jonathan Lang wrote:

> In this example, there's no difference between the Dog and Tree roles;
> however, this would almost certainly not be the case most of the time - at
> the very least, a class with a Dog role would have @.legs, while a class
> with the Tree role would have @.branches.  However, if all that happens
> when you specify a demand for the Dog role in a signature is that the
> object must meet Dog's demands, then both crossPerson and Trog will be
> accepted.  

I would consider that a mistake.

All that doing a role should imply is that somehow, that class
understands the syntax *and* semantics of the methods of that role. 
Introspection can't reliably reveal whether $some_object.bark accesses a
property (noun) or a method (verb).

It's true that looking for @.legs versus @.branches could get you
closer, but I'm not sure that it's been decided whether methods of a
role should blissfully ignore all of the object's state.  Besides, in a
delegation situation, there could easily be some sort of magic that
handles those attributes that the introspection mechanism might miss.

-- c


Thread Previous


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