[self-interest] "Organizing programs without classes"

Jecel Assumpcao Jr jecel at merlintec.com
Mon Nov 10 14:29:04 UTC 2003

On Monday 10 November 2003 08:35, J. Baltasar GarcĂ­a Perez-Schofield 
> ["polygon traits"=>draw(),copy()
>  "prototypical polygon"=>parent,"vertices"]

Slots with names ending in "*" indicate parents.

>          My question is: How's that possible ?
>          I mean, if the "draw" method is declared in the parent
> "traits", then it has no access to the vertices list, as they are
> declared in the "prototype".

Exactly. Sending 'draw' to 'traits polygon' will get you a "message not 
understood" error. That really bothers some people, though I don't 
worry much about it.

> So it is impossible to write a complete "draw" method.

Not if you think of 'vertices' as a method instead of an attribute.

> I suppose the list of vertices is declared in the
> "traits" object, at least in a minimalist way, and then repeated in
> its full format in the prototype polygon.

No, it is not present at all in the traits (and so 'draw' simply doesn't 
work for that object) but entirely defined in the prototype (so 'draw' 
does work for it, even though it is actually not defined in that object 
but inherited from the parent).

>          Or perhaps the "draw" method in the traits object is an
> empty one, and the method is repeated in the polygon prototype
> object.

Not that either. What you are missing are the advantages of entirely 
hiding state (attributes) behind behavior (getter and setter methods). 
For any object that inherits the 'draw' method and also understands the 
'vertices' message, 'draw' will work just fine.

-- Jecel

More information about the Self-interest mailing list