From: dblack@... Date: 2006-04-19T22:20:37+09:00 Subject: Re: interested in metaprogramming? Hi -- On Wed, 19 Apr 2006, Gregory Seidman wrote: > On Wed, Apr 19, 2006 at 06:31:47PM +0900, chiaro scuro wrote: > } two people is already a crowd to me :-) > } > } I'll let you know when I post more about metaprogramming and DSLs. > > I only skimmed what you've written so far, but I noticed that you've used > class_eval. It is preferable to avoid any form of eval whenever possible. > In your post you can replace... > > Array.class_eval do > synonym :size => [ :count, :n_elements ] > end > > ...with... > > Array.send(:synonym, :size => [ :count, :n_elements ]) > > ...to avoid the class_eval. I don't think instance_eval and class_eval, in their block forms, have the same issues as plain eval(string). class_eval is really just a closure cousin of the class keyword. David -- David A. Black (dblack@wobblini.net) Ruby Power and Light, LLC (http://www.rubypowerandlight.com) "Ruby for Rails" PDF now on sale! http://www.manning.com/black Paper version coming in early May!