From: Sean Middleditch Date: 2002-04-06T12:28:08+09:00 Subject: Re: Is eval a code/design smell? On Fri, 2002-04-05 at 05:26, Tobias Reif wrote: > Sean Middleditch wrote: > > > If you are > > dynamically generating code, you are probably doing things in a much > > uglier way than you should be > > > I don't see his. > > > (and Ruby should/does provide the faster, > > prettier ways of doing things). > > > For example? > > If I generate a lib from a schema, this takes some time for large schemas. > So I don't do this every time I use the lib, but simple load the > generated lib; fast. > No schema required anymore(in which case I would happily use eval.) > > What alternative would you suggest here? If eval() is running faster than your schema->lib functions, then I would simply say your functions are too slow. ^,^ I still don't see why Ruby shouldn't provide methods for quickly, easily, and powerfully constructing classes at runtime with sending untrustable content to the parsing engine. Because, I can just imagine someone downloading a schema from the web that has an embedded kernel.system('rm -rf $HOME/') - if you provide a schema in non-code format, that can be parsed in a safe manner that checks for this stuff. If you need to dump arbitrary objects (that might be valid to have a command to delete your home directory) it would probably be cleaner anyways to be able to serialize the bytecode/tree nodes, and store those; it would load even faster, and lend itself easier to progessive execution (if you're into that kind of masochistic activity... ~,^) > > > Tobi > > > -- > Neither simple nor complex matters are to be complicated. >