Nyquist / XLISP 2.0 - Contents | Tutorials | Examples | Reference

# Evaluation

1. with-errset - evaluate expressions without entering the Break Loop
2. apply* and funcall* - work also with macros and special forms

## with-errset

Evaluate an expression without entering the Break Loop on error or cerror:

    (defmacro with-errset (expr &optional (print-flag nil))
      `(progv '(*breakenable*) '(nil)
         (errset ,expr ,print-flag)))

See defmacro, errset, nil, &optional, progv.

Note: errset does not protect against the break function.

Back to top

## apply* and funcall*

In Lisp, macros and special forms are no functions. This means that apply and funcall only work with functions of type SUBR [built-in function] or CLOSURE [functions defined by defun, flet, labels, or lambda], but with macros and special forms a 'bad function' error is signalled. Here are two examples how to work around this behaviour:

    (defun apply* (function args)
      (eval (cons function args)))

    (defun funcall* (function args)
      (eval (cons function args)))

Warning: These functions can produce unwanted side-effects because macros and special forms do not need to conform to functional evaluation rules. Use them on your own risk.

Back to top

Nyquist / XLISP 2.0 - Contents | Tutorials | Examples | Reference