User Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

cl:special_operators:locally [2017/05/01 21:00] (current)
Line 1: Line 1:
 +====== Special Operator LOCALLY ======
 +
 +====Syntax====
 +  * **locally** //​declaration''​*''​ form''​*''//​ → //​result''​*''//​
 +
 +====Arguments and Values====
 +  * //​declaration//​ - a **[[CL:​Symbols:​declare]]** //​[[CL:​Glossary:​expression]]//;​ not evaluated.
 +  * //forms// - an //​[[CL:​Glossary:​implicit progn]]//.
 +  * //results// - the //​[[CL:​Glossary:​values]]//​ of the //forms//.
 +
 +====Description====
 +Sequentially evaluates a body of //forms// in a //​[[CL:​Glossary:​lexical environment]]//​ where the given //​declarations//​ have effect.
 +
 +====Examples====
 +<​blockquote>​
 +([[CL:​Macros:​defun]] sample-function (y) ; This y is regarded as special.
 +  ([[CL:​Symbols:​declare]] (special y))
 +    ([[CL:​Special Operators:​let]] ((y [[CL:​Constant Variables:​t]])) ​          ; This y is regarded as lexical. ​
 +      ([[CL:​Functions:​list]] y (locally ([[CL:​Symbols:​declare]] (special y))
 +                y))))      ; This y is regarded as special.
 +<​r>​SAMPLE-FUNCTION</​r>​
 +(sample-function [[CL:​Constant Variables:​nil]])
 +<​r>​([[CL:​Constant Variables:​t|T]] [[CL:​Constant Variables:​nil|NIL]])</​r>​
 +
 +([[CL:​Macros:​defparameter]] *x* '(1 2 3)) <​r>​*X*</​r>​
 +([[CL:​Macros:​defparameter]] *y* '(4 . 5)) <​r>​*Y*</​r>​
 +;;; The following declarations are not notably useful in specific. ​
 +;;; They just offer a sample of valid declaration syntax using LOCALLY.
 +(locally ([[CL:​Symbols:​declare]] ([[CL:​Declarations:​inline]] floor) ([[CL:​Declarations:​notinline]] car cdr))
 +         ​([[CL:​Symbols:​declare]] ([[CL:​Declarations:​optimize]] space))
 +  (floor (car *x*) (cdr *y*)))
 +<r>0
 +1</r>
 +
 +;;; This example shows a definition of a function that has a particular set of
 +;;; OPTIMIZE settings made locally to that definition.
 +(locally ([[CL:​Symbols:​declare]] ([[CL:​Declarations:​optimize]] (safety 3) (space 3) (speed 0)))
 +  ([[CL:​Macros:​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 ([[CL:​Declarations:​optimize]] (safety 3) (space 3) (speed 0)))
 +([[CL:​Macros:​defun]] frob (w x y &​optional (z (foo x y)))
 +  (mumble x y z w))
 +</​blockquote>​
 +
 +====Side Effects====
 +None.
 +
 +====Affected By====
 +None.
 +
 +====Exceptional Situations====
 +None.
 +
 +====See Also====
 +**[[CL:​Symbols:​declare|Symbol DECLARE]]**
 +
 +====Notes====
 +The **[[CL:​Declarations:​special]]** declaration may be used with **locally** to affect references to, rather than //​[[CL:​Glossary:​binding|bindings]]//​ of, //​[[CL:​Glossary:​variables]]//​.
 +
 +If a **locally** //​[[CL:​Glossary:​form]]//​ is a //​[[CL:​Glossary:​top level form]]//, the body //forms// are also processed as //​[[CL:​Glossary:​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}