Slots and methods.

Pupeno pupeno at pupeno.com
Sat Oct 23 22:09:24 PDT 2004


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

The recent bug that I reported here seems to confirm my doubt about this.
Let's supouse I have an object for a Circle, I create it like this:
addPrototype: #Circle derivedFrom: {Cloneable}.
Then, I want to store some data about this Circle, likes the coordinates of 
its center and its radius:
Circle addSlot: #x.
Circle addSlot: #y.
Circle addSlot: #radius.
and then I make some founctions that act on the circle:
c@(Circle traits) area
[
 pi * (c radius squared)
]
So I could make a circle by:
addSlot: #myCircle valued: Circle clone.
right ?
Then I could do:
myCircle area.
to get the area of my circle.
But since that founction can take Circle traits, I could also do 
myCircle traits area.
Which leads to the error:
The method #radius was not found for the following arguments:
{("Circle" parent0: ("Cloneable" ...). printName: 'Circle'. traits: 
("Traits" ...))}
I believe something is not right here, but I wouldn't know what... maybe you 
expect people to just not do this kind of thing. But when I start deriving 
from Circle (like when doing Ellipse and Pie), the problem may be hard to 
track. Basically, I'll have to be sure to reimplement all the founctions that 
take Circle traits to take Ellipse traits as well, and do nothing, or be sure 
that all the slot of Circle are pressented in Ellipse and Pie (something 
which might not be true). I believe that's what happened when trying to print 
Tuple traits, Vector and Point2D, right ?
Thanks.
- -- 
Pupeno: pupeno at pupeno.com - http://www.pupeno.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)

iD8DBQFBezkGfW48a9PWGkURAq4UAJ9ybzwscXB7ofaekQqs06Qh7/qkUwCeNyYR
EsssJ5lKRNkp1FiC2iU4gT0=
=8wBz
-----END PGP SIGNATURE-----




More information about the Slate mailing list