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).

>> You can ask it what its class is, what its ancestors are,
>> what methods it responds to, and so forth... but in the end, you hit
>> the singularity: the sending of the message.
>
> 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.
Objects can change, and classes are objects and can also change.

>> it stands
>> to reason that a language with objects whose types can change during
>> runtime would be well-served by a programming style that deals as
>> directly and economically as possible with precisely that condition.
>
> Hmmm. Is it that objects change their type, or is it that variables do?

Objects. Variables are untyped.

I always end up feeling in these discussions like it sounds like I'm
advocating some kind of wild, chaotic, pseudo-non-deterministic
programming style for Ruby. Far from it. I only want to point out that
Ruby imposes certain conditions on us (the changeability of objects),
and that I'd rather embrace that and try to find ways to leverage it
than interpret it as a language design flaw or a test of my resistance
to temptation.


David

-- 
Rails training from David A. Black and Ruby Power and Light:
   INTRO TO RAILS         June 9-12            Berlin
   ADVANCING WITH RAILS   June 16-19           Berlin
See http://www.rubypal.com for details and updates!