User Tools

A PCRE internal error occured. This might be caused by a faulty plugin

====== Function EVAL ====== ====Syntax==== * **eval** //form// → //result''*''// ====Arguments and Values==== * //form// - a //[[CL:Glossary:form]]//. * //results// - the //[[CL:Glossary:value|values]]// //[[CL:Glossary:yield|yielded]]// by the //[[CL:Glossary:evaluation]]// of //form//. ====Description==== Evaluates //form// in the current //[[CL:Glossary:dynamic environment]]// and the //[[CL:Glossary:null lexical environment]]//. **eval** is a user interface to the evaluator. The evaluator expands macro calls as if through the use of **[[CL:Functions:macroexpand-1]]**. Constants appearing in code processed by **eval** are not copied nor coalesced. The code resulting from the execution of **eval** references //[[CL:Glossary:object|objects]]// that are **[[CL:Functions:eql]]** to the corresponding //[[CL:Glossary:object|objects]]// in the source code. ====Examples==== <blockquote> ([[CL:Macros:defparameter]] *form* '([[CL:Functions:math-one-plus|1+]] a)) <r>*FORM*</r> ([[CL:Macros:defparameter]] *a* 999) <r>*A*</r> (eval form) <r>1000</r> (eval 'form) <r>(1+ A)</r> ([[CL:Special Operators:let]] ((a '(this would break if eval used local value))) (eval form)) <r>1000</r> </blockquote> ====Affected By==== None. ====Exceptional Situations==== None. ====See Also==== **[[CL:Functions:macroexpand-1|Function MACROEXPAND-1]]**, {\secref\EvaluationModel} ====Notes==== To obtain the current dynamic value of a //[[CL:Glossary:symbol]]//, use of **[[CL:Functions:symbol-value]]** is equivalent (and usually preferable) to use of **eval**. Note that an **eval** //[[CL:Glossary:form]]// involves two levels of //[[CL:Glossary:evaluation]]// for its //[[CL:Glossary:argument]]//. First, //form// is //[[CL:Glossary:evaluated]]// by the normal argument evaluation mechanism as would occur with any //[[CL:Glossary:call]]//. The //[[CL:Glossary:object]]// that results from this normal //[[CL:Glossary:argument]]// //[[CL:Glossary:evaluation]]// becomes the //[[CL:Glossary:value]]// of the //form// //[[CL:Glossary:parameter]]//, and is then //[[CL:Glossary:evaluated]]// as part of the **eval** //[[CL:Glossary:form]]//. For example: <blockquote> (eval ([[CL:Functions:list]] '[[CL:Functions:cdr]] ([[CL:Functions:car]] '(([[CL:Special Operators:quote]] (a . b)) c)))) <r>B</r> </blockquote> The //[[CL:Glossary:argument]]// //[[CL:Glossary:form]]// <blockquote> ([[CL:Functions:list]] '[[CL:Functions:cdr]] ([[CL:Functions:car]] '(([[CL:Special Operators:quote]] (a . b)) c))) </blockquote> is evaluated in the usual way to produce the //[[CL:Glossary:argument]]// <blockquote> ([[CL:Functions:cdr]] ([[CL:Special Operators:quote]] (a . b))) </blockquote> **eval** then evaluates its //[[CL:Glossary:argument]]//, <blockquote> ([[CL:Functions:cdr]] ([[CL:Special Operators:quote]] (a . b))) </blockquote> to produce ''b''. Since a single //[[CL:Glossary:evaluation]]// already occurs for any //[[CL:Glossary:argument]]// //[[CL:Glossary:form]]// in any //[[CL:Glossary:function form]]//, **eval** is sometimes said to perform "an extra level of evaluation." \issue{QUOTE-SEMANTICS:NO-COPYING} \issue{EVALHOOK-STEP-CONFUSION:X3J13-NOV-89} \issue{EVALHOOK-STEP-CONFUSION:FIX}