From: avi@...4.com (Avi Bryant) Date: 2002-04-05T07:32:59+09:00 Subject: Re: Is eval a code/design smell? Sean Middleditch wrote in message news:<1017933822.1548.12.camel@smiddle>... > To me, that is indeed a language flaw. There should be > methods that don't open up the security holes of eval() for > finding/setting attributes of an object. Your specific need for no > initialize() still seems weird to me, but if it is necessary, and the > language restricts you from doing it, then either the language is flawed > or you are using the wrong langauge for the task. Nonsense. It's impossible to predict everything a language is going to be used for; the important thing is to make it extensible enough so that people can build whatever they need on top of it. Is Ruby "flawed" because it doesn't ship with an XML parser? No, because you can write one in it. Ruby lets you extend its base types, so any methods missing from those types can't be seen as flaws. Moreover, Ruby provides eval, which is a very powerful way to build the added functionality you need. If it didn't provide eval, and there was no way to add it, then you can start talking about flaws. You're discussing a method that's 2 lines of Ruby or maybe 6 lines of C - does the requirement to write them make it the "wrong language for the task"?? > People have built applications that do everything Ruby can do in C, and > done it faster than the Ruby interpreter could do it (although with a > lot more work than Ruby would require) without ever having an eval() for > C code. ~,^ Turing tar pit. So what - are you recommending we write everything in machine code? And who says you can't eval C code? Write it to disk, compile it into an .so, and load it. Grumpily yours, Avi