Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EVAL in SCHEME

Tags:

scheme

Peter Norvig in PAIP says:

in modern lisps...eval is used less often (in fact, in Scheme there is no eval at all). If you find yourself using eval, you are probably doing the wrong thing

What are some of the ways to circumvent using eval in scheme? Arent there case where eval is absolutely necessary?

like image 499
unj2 Avatar asked Jun 25 '09 15:06

unj2


People also ask

What is eval and apply?

EVAL executes arbitrary source code made of Lisp's data structures. This includes function calls, macro forms, special forms, variables and self-evaluating data. APPLY applies a function to a list of arguments.

What are the functions of Scheme?

Like all programming languages, Scheme allows us to build our own procedures and add them to the set of existing ones. Very few implementations of Scheme even distinguish between the built-in functions and the user-defined ones. symbol and a set of parameters with a parameterized expression.


1 Answers

There are cases where eval is necessary, but they always involve advanced programs that do things like dynamically loading some code (eg, a servlet in a web server). As for a way to "circumvent" using it -- that depends on the actual problem you're trying to solve, there's no magic solution to avoiding eval except for ... eval.

(BTW, my guess is that PAIP was written a long time ago, before eval was added to the Scheme Report.)

like image 143
Eli Barzilay Avatar answered Oct 12 '22 14:10

Eli Barzilay