Peter Norwig in PAIP says:"in modern lisps ... eval is used less often (in fact, there is no rating in Scheme)" "if you find yourself using eval, you are probably mistaken."
What are some ways to get around using the eval schema? Arent where eval is absolutely necessary?
There are times when required eval, but they always include advanced programs that perform functions such as dynamically loading some code (for example, a servlet on a web server). As a method to "bypass" its use - it depends on the specific problem you are trying to solve, there is no magic solution for avoiding evalthe exception ... eval.
eval
(By the way, I assume that PAIP was written a long time before it evalwas added to the schema report.)
He is mistaken. Of course, there is a scheme eval.
eval . , , - . , . , . eval , lisp .
( ), , , .
, eval, .
, Scheme eval, , , Scheme (R5RS ). , , , .
, eval . -, , , :
, Scheme, eval , . , Scheme - , Scheme " ".
, eval . eval , . , eval, , , , ( !).
-, PAIP Common Lisp, Scheme, , . CL- , eval, , , . eval Common Lisp, .
. , Lisp. , , , .
-, , ", , ", " ". , , , , eval . , C, goto, , goto , .
goto
, "eval" , - . , psuedo-C:
param = read_integer(); fn = eval("int lambda(int x) { int param = " + to_string(param) + "; return param*x; }");
, . ? . Scheme Lisps eval.
(define make-my-fn (lambda (param) (lambda (x) (* param x))) (let* ([ param (read-integer) ] [ fn (make-my-fn param ]) ;; etc. )
. , , , .
, , , , .:)