From: chiaro scuro Date: 2006-04-19T23:00:39+09:00 Subject: Re: interested in metaprogramming? what about using define_method from ruby1.8.4 ? it also accepts a block as argument.. alternatively it will look nicer to use the eval %{ .... } notation than the HEREDOC. if you use heredoc you coud do it this way, to convey the meaning that the sting represents code: eval <<-CODE sdjifklsdnkdfksd dl�sdkl�l�fsd�s CODE On 4/19/06, Robert Dober wrote: > On 4/19/06, 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... > > > Could not agree more but I am desperately looking for a way to replace this > which I use *very* often > > class Mine > eval <<-EOS > def #{name}( value, &block ) > do_something( &block ) if block_given? > end > EOS > end > I'd *love* to do it with define_method, but I do not get around the "&block" > parameter. > > Anybody help? > > Thx > Robert > > > > > -- > Deux choses sont infinies : l'univers et la b�tise humaine ; en ce qui > concerne l'univers, je n'en ai pas acquis la certitude absolue. > > - Albert Einstein > > -- Chiaroscuro --- Liquid Development: http://liquiddevelopment.blogspot.com/