User Tools


Special Operator LOCALLY

Syntax

  • locally declaration* form*result*

Arguments and Values

Description

Sequentially evaluates a body of forms in a lexical environment where the given declarations have effect.

Examples

(defun sample-function (y) ; This y is regarded as special. (declare (special y)) (let ((y t)) ; This y is regarded as lexical. (list y (locally (declare (special y)) y)))) ; This y is regarded as special.

SAMPLE-FUNCTION

(sample-function nil)

(T NIL)

(defparameter *x* '(1 2 3))

*X*

(defparameter *y* '(4 . 5))

*Y*

;;; The following declarations are not notably useful in specific. ;;; They just offer a sample of valid declaration syntax using LOCALLY. (locally (declare (inline floor) (notinline car cdr)) (declare (optimize space)) (floor (car *x*) (cdr *y*)))

0 1

;;; This example shows a definition of a function that has a particular set of ;;; OPTIMIZE settings made locally to that definition. (locally (declare (optimize (safety 3) (space 3) (speed 0))) (defun frob (w x y &optional (z (foo x y))) (mumble x y z w)))

;;; This is like the previous example, except that the optimize settings remain ;;; in effect for subsequent definitions in the same compilation unit. (declaim (optimize (safety 3) (space 3) (speed 0))) (defun frob (w x y &optional (z (foo x y))) (mumble x y z w))

Side Effects

None.

Affected By

None.

Exceptional Situations

None.

See Also

Notes

The special declaration may be used with locally to affect references to, rather than bindings of, variables.

If a locally form is a top level form, the body forms are also processed as top level forms. see section {\secref\FileCompilation}.

\issue{LOCALLY-TOP-LEVEL:SPECIAL-FORM} \issue{DECLS-AND-DOC} \issue{LOCALLY-TOP-LEVEL:SPECIAL-FORM} \issue{RETURN-VALUES-UNSPECIFIED:SPECIFY} \issue{LOCALLY-TOP-LEVEL:SPECIAL-FORM}