--- "David A. Black" <dblack / wobblini.net> wrote:

> Hi --
> 
> On Fri, 30 Sep 2005, Bob Hutchison wrote:
> 
> > Where do you stop? Why inherit at all? How do you decide?
> >
> > [I sympathise with this, I've always preferred composition
> to inheritance. 
> > Worse still, I went to the OOPSLA'87 (Orlando anyway, think
> it was 1987) 
> > conference because I didn't 'get' OO and was hoping to
> figure it out. I 
> > mentioned this to someone I was sitting beside and was
> treated to a lesson 
> > over lunch (maybe breakfast, can't remember). This person
> was David Unger, 
> > one of the key people responsible for self and the
> alternate OO model, 
> > delegation/prototype, to Ruby's class-based OO model. So I
> was indoctrinated 
> > early by one of the best :-) The "Treaty of Orlando"
> <http:// 
> > citeseer.ist.psu.edu/stein89shared.html> came out of that
> conference.]
> 
> I sometimes wonder how class-based Ruby's model is.  Or maybe
> it's a
> hybrid.  I don't know any purely prototyped languages, so I
> can't
> compare directly, but I always think of a class in Ruby as a
> mechanism
> for bootstrapping objects into object-space -- at which point
> the
> objects have nothing further to do with the class, except
> that some
> subset of the class's instance methods may continue to serve
> as a
> subset of the methods of the object.  (But it never has to;
> that's
> just a convenient default.)
> 
> It's the old "class != type in Ruby" thing.  I wonder whether
> Ruby's
> potential to be regarded as a prototyped language simply has
> yet to be
> fully explored.
> 
>    module Kernel
>      undef :kind_of?, :is_a?  # maybe a few others
>    end


It looks like ruby does prototyping just fine since each object
can have its own meta class:

class Object
  def meta_class
    class << self;self;end
  end
end

a = Object.new
a.meta_class.class_eval { def foo;"a";end }
b = a.clone
p a.foo # => "a"
p b.foo # => "a"

b.meta_class.class_eval { def foo;"b";end }
p a.foo # => "a"
p b.foo # => "b"

a.meta_class.class_eval { def foo;"A";end }
p a.foo # => "A"
p b.foo # => "b"

I'm not sure how memory efficient this would be compared to a
pure prototyping language though.  Not sure if initially b
(directly from a.clone) shares the "foo" definition or not.


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com