From: Avi Bryant Date: 2001-03-06T00:46:38+09:00 Subject: [ruby-talk:12032] Re: ANN: Memoize 0.1.2 On Tue, 6 Mar 2001, Robert Feldt wrote: > Can you summarize what is the essential feature the c code in advice.c > adds to Ruby that you cannot do in Ruby directly. I sure like advice.c but > would like to do it without resorting to C, if possible. (I guess this is > a dumb question since you wrote it in C and thus probably don't know how > to do it cleanly in Ruby; if so please discard ;-)) It could be written in Ruby, in the same style as the current incarnation of AspectR - doing a lot of fragile, special-cased syntax generation and calling instance_eval. What doing it in C allows is to have one, generalized dispatcher that can still easily find out a) which method was called to get to the dispatcher, and b) which object it was called on. In Ruby, you could have a generalized dispatcher using define_method with a block, but then the block has the wrong context (no knowledge of "self" or of which method was called). I don't see having a very short C extension of the runtime on which to build more complex AOP structures as being that evil, personally... after all (for now) we still depend on a C interpreter. The ideal, really, would be to have built in support for alternate dispatchers - that is, to truly be able to redefine send, whether in C or in Ruby. Avi