Function Entry: EVAL

← Prev | ↑ Chapter | Next → | Index | Symbols

Function Entry: EVAL

Name

eval

Class

Function

Syntax

(eval expr)

Arguments and Values

  • expr: any AutoLISP expression. Documented value types are integer, real, string, list, symbol, ename, T, or nil.

Description

Returns the result of evaluating an AutoLISP expression. eval is an ordinary function, so evaluation happens in two stages: the argument form is first evaluated by the normal call-argument machinery of the caller, and the resulting value is then evaluated a second time by eval. The pedagogical point of eval is precisely this second evaluation; it only does observable work when the first evaluation yields an unevaluated form (a symbol to resolve, or a list to evaluate as a call). When the first evaluation yields a self-evaluating value (a number, string, T, or nil), the second evaluation returns it unchanged and eval appears to do nothing.

Return Values

Returns the value produced by the second evaluation of expr. The return type follows the resulting form and is one of integer, real, string, list, ename, T, or nil.

Side Effects

Side effects are those of the evaluated expression.

Examples

Given (setq a 123) and (setq b 'a):

Self-evaluating edge case (the second evaluation has no work to do):

  • (eval 4.0) returns 4.0. eval receives 4.0 (the argument is already evaluated); 4.0 self-evaluates to 4.0.

Significative cases (the first evaluation yields a form, so the second evaluation does real work):

  • (eval '(+ 1 2)) returns 3. The argument '(+ 1 2) evaluates to the list (+ 1 2); eval then evaluates that list as a form, giving 3.
  • (eval (list '+ 'a b)) returns 246. (list '+ 'a b) evaluates to (+ A A) — because `' yields the symbol +, 'a yields the symbol A, and b yields A (its value, the symbol a); eval then evaluates ( A A), and A is bound to 123, giving 246. Equivalent to (eval '(+ A A))`.
  • (eval b) returns 123. This is a two-step evaluation: the argument b evaluates to the symbol A (since (setq b 'a)), and eval then evaluates the symbol A, which is bound to 123. Contrast (eval a), whose argument a already evaluates to 123, a self-evaluating number, so eval returns 123 without further work.

Availability

  • AutoCAD 2026: documented.
  • BricsCAD V26: presumed compatible (no contradicting page found).
  • Status: AutoCAD documented; BricsCAD presumed-both pending Phase 4 verification.