In 4.1.3 Evaluator Data Structures of SICP, it states:
That the user's programs are the evaluator's data need not be a source of confusion. In fact, it is sometimes convenient to ignore this distinction, and to give the user the ability to explicitly evaluate a data object as a Lisp expression, by making eval available for use in programs. Many Lisp dialects provide a primitive eval procedure that takes as arguments an expression and an environment and evaluates the expression relative to the environment.
Then experiment with
Chez Scheme Version 9.5
Copyright 1984-2017 Cisco Systems, Inc.
> (define a 5)
> (define b 6)
> (eval '(* a b))
30
I think the result not make sense, since it does both eval and apply.
As I learned from the proceeding contents, I predict the result should be
> (eval '(* a b))
'(* (5 6))
Then apply * to list-of-values (5 6).
Eval produce value of arguments and procedures to be applied rather than a final result.
Am I wrong with the understanding of eval?
(* a b)
by itself evaluates to 30, not(* 5 6)
. – chepnereval
ing an expression evaluates it completely. – molbdnilo(* 2 3)
:(eval ''(* 2 3))
. Notice the double quoting. – Flux