On Tue, 25 Nov 2003, David A. Black wrote:

> eval is not for constructing code piecemeal with various variables.
> eval is for evaluating strings as code at runtime.

A classic of evaluating strings is evaluating SQL code, and almost
invariably it involves inserting into a SQL code string some values coming
from the surrounding language. Those values must be converted
appropriately and safely, e.g. strings must be properly quoted. Then the
"?" placeholder has been introduced specially for that purpose.

In this case, it's almost the same situation, but about embedding Ruby
code into Ruby code.

I wanted to show that there is prior art for that feature, and that it's
in wide use.

> You can't solve every programming issue by introducing a new feature
> to the language, coming up with new (but usually already in-use)
> syntax, or redefining concepts like runtime string evaluation to fit
> one or two particular cases for which it isn't the right answer in the
> first place.

I've hit that problem before while writing a code generator in Ruby, 2
years ago. But I don't quite recall how I solved the problem, but it may
have been using class variables or even global variables. Their use is
pretty much justified when there's no other workaround that makes sense.

> Speaking of "core language", I'm not sure what this is doing on this
> list.  It belongs on ruby-talk, or perhaps on a wiki somewhere. So....  
> <http://www.rubygarden.org/ruby?EvalAndScope>.  I honestly think
> that's a better place for wide-ranging, open-ended, speculative
> discussions of the nature of string evaluation and so on.

Then I don't quite know what this mailinglist is for... I thought
ruby-core was shorthand for hardcore ruby, i mean with the black leather
and such, for the kinkier of us. ;-)

________________________________________________________________
Mathieu Bouchard                       http://artengine.ca/matju