Hi -- On Mon, 15 May 2006, Jake McArthur wrote: > On May 15, 2006, at 12:33 AM, dblack / wobblini.net wrote: > >> It sounds like you're talking about class, rather than type. A >> string, for example (that is, an object that says "String" when you >> ask it its class), can allow integers to be added to it, and is >> therefore of class String but of *type* "string-like thing that lets >> you add integers to it" (or whatever). >> >> So the type of Ruby objects is almost a tautology: the type of object >> o is "the type of objects that have the capabilities and interface of >> object o." Class, meanwhile, though more tangible in a sense, is only >> the starting point for the object's life-cycle. > Agreed. In fact, at its core, I would say that Ruby is "untyped," since > everything is of the same type (Object). The only meaningful information > about the qualifications of an object for a certain task is whether it > responds to certain necessary methods, as you said. Based on this, I would > say that Ruby simply attempts to blindly execute the code with _no_ type > checking at all, but simply chokes if a method is missing. Is this a bad way > to think of it? I would apply the word "class" to Object (rather than type), and leave "type" available for that other thing you're talking about -- the thing where a given object can do some things and not do others. People sometimes refer to this as an object's "duck type", but it's really just its type (and duck typing is, in my view, simply programming in Ruby in a way that embraces how type [not "duck type"] operates). I think it's right to say that variables are untyped, but not that objects are. It's true, though, that type -- understood as the aggregate of an object's capabilities at some given point in runtime -- is almost an invisible concept. No designation or discussion of an object's type actually has any bearing on what happens when that object gets sent a message. Of course the vast majority of Ruby objects that get created do not, in fact, deviate from the type laid down by their class. But when they do, the only way to understand what's happening is to have understood already that they *can*. Without that understanding, even something like class methods (where a particular Class instance deviates from the type of a freshly-created Class instance) becomes a huge mystery. And then we start hearing about running with scissors, and rope and shooting in foot, and all that :-) David -- David A. Black (dblack / wobblini.net) * Ruby Power and Light, LLC (http://www.rubypowerandlight.com) > Ruby and Rails consultancy and training * Author of "Ruby for Rails" from Manning Publications! > http://www.manning.com/black