National Institute of Advanced Industrial Science and Technology (AIST) This page is a page of the former research institute. We stopped updating on March 31.2001.
E-mail to webmaster (Japanese) E-mail to webmaster (English)
next up previous contents index
Next: Top-level Interaction Up: Evaluation Previous: Evaluation

Evaluators

In order to specify the behaviors upon an error and an interrupt(signal), set an appropriate function to each of the special variables *error-handler* and *signal-handler* in advance. There is no correctable or continue-able error. After analyzing errors you must abort the current execution by reset or appropriate throw to upper level catchers. reset is equivalent to (throw 0 NIL), since EusLisp's top-level creates catch frame named 0.

Error handlers should be programmed as functions with three or four arguments: code msg1 form &optional (msg2). Code is the error code which identifies system defined errors, such as 14 for 'mismatch argument' or 13 for 'undefined function'. These mappings are described in "c/eus.h". msg1 and msg1 are messages displayed to the user. form is the S-expression which caused the error.

Signal handlers should be programmed as functions receiving two arguments: sig and code. Sig is the signal number ranging from 1 to 31, and code is the minor signal code defined in signal-number dependent manners.

^D (end-of-file) at the top-level terminates eus session. This is useful when eus is programmed as a filter.

Eval-dynamic is the function to find the dynamic value bound to a symbol used as a let or lambda variable. This is useful for debugging.

  identity obj [function]

  eval form [environment] [function]   apply func &rest args [function]   funcall func &rest args [function]
  • applies func to args. The number of args must coincide to the number of arguments the func requests.
  quote obj [special]
  • evaluates to obj itself.
  function func [special]
  • makes a function closure. If func is a symbol, its function definition is retrieved.
  evalhook hookfunc form [env] [function]
  • evaluates form once after binding hookfunc to *evalhook*.
  eval-dynamic variable [function]
  • finds the value of variable (symbol) on the stack.
  macroexpand form [function]
  • expands form if it is a macro call. If form is expanded to a macro call again, expansion is repeated until non macro call results.
  eval-when situation {form}* [special]
  • Situation is a list of compile, load and eval. Forms are evaluated when the current execution mode matches with situation. eval-when is important to control the behavior and environment of the compiler. If compile is specified, forms are evaluated by the compiler so that the result will affect the consequent compilation. For example, defmacro should be evaluated by the compiler in order to let the compiler expand macro calls at compile time. If load is given in the situation list, forms are compiled to be loaded (evaluated) at load time, i.e., compiled functions are defined at load time. This is the normal effect that we expect to the compiler. load situation is used to control the compiler's environment. If eval is included in situation list, forms are evaluated when their source code is loaded.
  the type form [special]
  • Declares form is of type. type is either a class object, :integer, :fixnum, or :float.
  declare declaration* [special]
  • Each declaration is a list of a declaration specifier and an integer or target symbols. Declarations are important to let the compiler produce faster code.
    special declares special variables
    type declares the type of variables; (type integer count); valid type specifiers are  integer,  :integer  fixnum,  :float and  float. The type keyword may be omitted if type specifier is either one listed here. So (integer count) is a correct declaration. Other types (classes) such as float-vector, integer-vector, etc. need to be preceded by type, as (type float-vector vec1).
    ftype declares the result type of functions
    optimize set *optimize* parameter (0-3) of the compiler
    safety set *safety* parameter (0-3) of the compiler
    space set *space* parameter (0-3) of the compiler
    inline not recognized
    not-inline not recognized

  proclaim proclamation [function]
  • globally declares the types of variables and compiler options. The same declarations are accepted as described for declare special form. However, proclaim is a function of one argument and proclamation is evaluated.
  warn format-string &rest args [function]
  • prints warning-message given as format-string and args to *error-output*.
  error format-string &rest args [function]
  • calls the current error-handler function bound to *error-handler*. The default error-handler 'euserror' first prints arguments to *error-output* using format, then enters a new top level session. The prompt shows you the depth of your error session. Throwing to the number, you can go back to the lower level error session.
In the multithread EusLisp, special variables are shared among threads and the same *error-handler* is referenced by different threads. To avoid this inconvenience, multithread EusLisp provides the install-error-handler function which installs different error handler for each thread.

  install-error-handler handler [function]

  • installs the handler as the error handler of the current thread.


next up previous contents index
Next: Top-level Interaction Up: Evaluation Previous: Evaluation

Hirofumi Nakagaki
Fri Mar 22 12:46:38 JST 1996