From: Christian Szegedy Date: 2002-09-06T20:50:32+09:00 Subject: Re: Ruby aesthetics ts wrote: >>>>>>"C" == Christian Szegedy writes: >>>>> > > C> If you adapt this solution, then you will have to have the id of the class > C> when wou compile the def. (As I mentionned in my original mail). > C> Is it an inherent problem? > > With > > class A > def a > @_m = 12 > end > end > > when ruby _compile_ the def, the class A (i.e. the object) don't exist > > > Guy Decoux > > I think, I see a somewhat hacky but realistic solution: I would modify eval.c where the nodes are evaluated and (rb_add_method is added) the case DEFN of part of the huge switch. I assume here that the method definition contains a reference to a private member (otherwise no action is required, this could be checked by a flag in the source tree stored for quick access while parsing) Before the point where Ruby calls the rb_add_method, it copies the whole subtree of the method definition and changes all nodes referencing the private data members, and passes the root of the new subtree to rb_add_method. (Of course there are cleaner but less efficient solutions.) Best regards, Christian