On Friday 30 May 2008 18:21:51 David A. Black wrote:
> Hi --
> 
> On Fri, 30 May 2008, Mark Wilden wrote:
> 
> > On May 29, 2008, at 3:37 AM, David A. Black wrote:
> >
> >> Duck typing, as a way of thinking, meshes nicely with Ruby, as a tool,
> >> because of how Ruby objects are engineered: the *only* thing that you
> >> can measure with certainty is what an object does when you send it a
> >> message.
> >
> > No, you cannot possibly measure with certainty what an object does when 
you 
> > send it a message. The only thing you can measure is whether it will throw 
a 
> > runtime error because it doesn't implement a method for the message.
> 
> I mean you can measure what it's done after it's done it. I don't mean
> you can measure what it *will* do; that's precisely my point (you
> can't).

As long as we're nitpicking, you can't necessarily measure what's happened 
after the fact, either. The object may well swallow everything with 
method_missing and do nothing. It may be possible to play tricks with 
respond_to?, __send__, and so on, to achieve the same effect.

After all, your only way to check what goes on inside the class is to ask it, 
by sending a message.

Of course, at this point, it doesn't really matter. Your definition of success 
is probably based on what your program actually does -- what it actually 
inputs and outputs -- and not on the internal state of some object.

> > However, an object's class and ancestors _determine_ what messages an 
object 
> > responds to. That's what they're there for - to hold message maps.
> 
> No; they determine what messages a freshly-minted object responds to.

Unless I override #new, or #method_missing, or a number of other tricks.