On Friday 16 November 2001 09:20 am, you wrote:
> >>>>> "Albert" == Albert Wagner <alwagner / tcac.net> writes:
>
> Albert> Just curious, what did you expect to happen?  What model do
> Albert> you hold in your head concerning names and inheritance that is
> Albert> violated by misnaming an object?
>
> Educationnal purpose, not efficiency...
>
> In fact, "my head" has some problem to justify that there is two
> objects of different classes that can be assigned to each other (i'm
> rather experienced with strong typing languages).

Uhm, objects cannot be assigned to each other in Ruby. You are confusing the
name of an object with the object itself. If I say

   foo=Stat.new("/") 

I am creating a stat object, and associating it with the name "foo" -- but 
"foo" is not an object. "foo" is just the name of an object. The object 
itself is a totally independent thingy living somewhere out there on some 
system "heap". If I later say

   foo="This is a test"

I have not somehow "assigned to an object". No, now I'm just associating the 
name "foo" with a different object.

   If I later use the name 'foo' in an expression, I'm saying "the object 
that I've currently named 'foo'". 'foo' itself is not an object. 'foo' is 
just the name of an object. The object itself may have several names. 

 bar=foo + " of the emergency broadcasting system"

What happens there is that whenever I see the name "foo", I go look for the 
object that it happens to be naming at the moment, and then use that 
object in the expression. So an object "This is a test of the emergency 
broadcasting system" is created somewhere out there in "object space", and 
I'm associating it with the name "bar". 

If, on the other hand, I'd said

  foo=1
  bar=foo+"emergency"

Ruby would look for the "+" method of the object that I've currently named 
"foo" (an Integer object in this case), + would be called, would see that its 
argument is a String object, and say "Sorry, I can't do that!" and throw an 
exception.

That is, objects themselves *DO* have a strict type associated with them. 
This strict type, however, does not depend on whatever name I'm referring to 
it by at any given time.

This is not a new concept. Lisp did this 40 years ago. For that matter, 
mathematicians did this at least 500 years ago, when they invented the 
concept of "algebra" -- i.e., when they invented the concept that an object 
(a number) and its name (whether a digit or an arbitrary letter) are two 
different entities altogether. Anybody familiar with any mathematics past 
"Calculus for Engineering Grunts" will be right at home here. Anybody who 
knows what the Peano Postulates are should have no problem at all with this 
concept. 

For that matter, my high school Algebra I students had no problem with the 
concept of the difference between an object and its name, once I put it into 
terms of physical objects like people. Whether I call the basketball player 
"Anafree" or "Penny" or nothing at all, he still scores 3-pointers as well 
and drives the baseline as well. Same deal with whether I call him "Shaq" or 
"Shaquille" or "That big lunk with the Lakers who can't shoot free throws" 
:-).

> Dynamic typing has a lot of advantages, 

But Ruby doesn't do dynamic typing. Objects in Ruby are strictly typed. Every 
object in Ruby belongs to a particular Class (type), and if you try to, e.g.,
add an Integer and a String, Ruby will not allow it. But yes, I can at 
various times during the execution of a program use the same name for objects 
of different types. But that's just names. That has nothing to do with whether
Ruby is strictly typed or not. 

-- 
Eric Lee Green          GnuPG public key at http://badtux.org/eric/eric.gpg
           mailto:eric / badtux.org  Web: http://www.badtux.org
             You do not save freedom by destroying freedom