From: Ron Jeffries Date: 2002-04-04T09:50:45+09:00 Subject: Re: Is eval a code/design smell? On 3 Apr 2002 12:32:48 -0800, avi@beta4.com (Avi Bryant) wrote: >I never use eval. However, I use module_eval all the time. That is, >although I never use eval at "runtime", it's extremely useful at, err, >"compile" time, to generate code. Look at AspectR or my work a while >ago on the Kansas O/R mapping for some examples of this; for an >extreme example, look at Matju's X11 implementation. For a less >extreme example, consider this - every time you use attr_accessor, >you're effectively using eval. > >Now, in lisp, most of these uses would become macros instead, which I >think is ultimately a better solution. But until someone gets around >to porting dylan's macro system to Ruby, those of us who can't live >without metaprogramming will have to make do with eval. Yes, eval or its brethren are very useful for code generation. Although in many cases I'd rather generate the actual source. Good example! Ronald E Jeffries http://www.XProgramming.com http://www.objectmentor.com I'm giving the best advice I have. You get to decide whether it's true for you.