From: "ara.t.howard" Date: 2007-06-06T06:49:08+09:00 Subject: Re: [ANN] prototype-2.0.0 On Jun 5, 2007, at 2:33 PM, Victor "Zverok" Shepelev wrote: > From: ara.t.howard [mailto:ara.t.howard@gmail.com] > Sent: Tuesday, June 05, 2007 11:03 PM >> On Jun 5, 2007, at 12:55 PM, Victor Zverok Shepelev wrote: >> >>> From: ara.t.howard [mailto:ara.t.howard@gmail.com] >>> Sent: Tuesday, June 05, 2007 6:33 AM >>> >>> >>>> NAME >>>> prototype.rb >>>> >>> >>> Several small questions about the library: >>> >>> * Does cloned object has some connections with it's prototype (as >>> per Io: >>> "prototype is something knowing how to process messages I don't >>> know") >>> >> >> yes. if one does >> >> clone = Object.prototype{ @a = 42 }.clone >> >> the clone has a #a method from parent and @a instance var if it's own > > It's understandable. I've meant the case > > a = Object.prototype{ @x = 42 } > > b = a.clone > > a.extend { > def my_new_method; puts "here!" end > } > > b.my_new_method #will b have ALL the methods of it's prototype? the first impl did indeed to that. the latest does not. i found it flew in the face of 'normal' ruby design patterns - which is where i'm using it after all! ;-) > > assert_equal b.prototype, a #is there a way to obtain b's prototype? > hmmm. i think the closest thing would be assert a.class === b prototype sets up what you would consider a 'normal' ruby hierarchy. that is to say clones are created from a subclass of the cloner's class. > #we also can think this way: > def b.method_missing(:sym) > self.prototype.send(:sym) > end > > I'm not prototype-based guru, of course. > me neither! > What I want to say. I've started to think about prototype-based > programming > from Io and JavaScript. My very first impression was "I create > objects, I > clone objects, that's all". But further I've found, the more > experienced > people think about prototype-based as "each object has it's > prototype" first > of all (which becames "object's prototype processes all unknown > signals", > "object's prototype can be changed" and even Io's "prototype > defines lexical > scope"). > > It seems prototype.rb now does something like "my first > impression", not > "prototype-based entirely". > > Am I wrong? you are right. i may look into making it closer to the latter in the future. kind regards. -a -- we can deny everything, except that we have the possibility of being better. simply reflect on that. h.h. the 14th dalai lama