From: Jim Menard Date: 2003-03-25T00:38:26+09:00 Subject: Re: Types (was Re: Ruby lecture slides (was Strong advantages over Python)) Jim Freeze writes: > Thanks for the fine example, but for those of us who are a little slow, > what exactly are the types of 'f' and 'o'? I think of types as promises to implement certain behaviors. (Is that vague enough for you?) An object may have more than one type since it can implement more than one set of behaviors. This can be made explicit in some languages. Java's interfaces are a nice way of doing this (though they are made less useful than they may have been because you can't provide any implementation in a Java interface). Both 'f' and 'o' implement the same 'shout' behavior, so they both have the same type---at least from the perspective of the user who needs to call 'shout'. Sometimes I think of types as being defined not by the objects that implement them but rather by the users of those objects. The users require objects that do X and Y. If I implement X and Y, I am therefore useful to those users and implement the type that they need. Jim -- Jim Menard, jimm@io.com, http://www.io.com/~jimm/ "Mind you, deep in the IBM VM operating system source we once found a comment that said 'remember to collect laundry on way home'." -- Alan J. Flavell in comp.lang.perl.misc