fogus wrote:I have often heard that explicitly calling (eval) or (compile) explicitly is considered bad form. I can (in theory) understand the knocks against eval as outlined in On Lisp (i.e. inefficient, devoid of lexical context), but it seems to me, as an outsider, that eval and compile would be perfect for building functions programmatically (although not closures if I understand correctly). What am I missing? Is there a better way?
Not lame, so much as the wrong tool for the job, usually. If you read a line from the user and want to evaluate it, by all means, use EVAL. But for creating functions at compile time or run time, usually the most appropriate tool is a macro or a function that returns a closure.
If you come from a C background, it may be hard to wrap your head around a function or a closure as a first class object, meaning you can pass it around to other functions and do stuff with it. In C, you can take the address of a function, give that to somebody else, and they can call it, but not much else. In Lisp, a closure is a piece of code with certain variables "closed over", or left over (not a good description, but the best I can think of at the moment) from the lexical context of the closure definition.
My point being, in C a function is something only the compiler knows about. In Lisp, a function is just a symbol that points to a closure, and you can make closures yourself without using EVAL or COMPILE.
Last, if you can't think of how to do what you want to do without using EVAL, do it. As you learn more Lisp, you'll figure out better ways. No harm, no foul. (Just don't do it in production code for your boss or business, 'cause there it *will* harm you.