• Aucun résultat trouvé

193 sys:dynamic-closure

Dans le document Symbolics Common Lisp: Language Dictionary (Page 196-200)

Examples:

(dpb 1 (byte 1 2) 1) => 5

(dpb 8 (byte 1 31.) -1_31.) => -4294967296.

(dpb -1 (byte 48. 8) -1_32.) => -1.

(dpb #0238 (byte 6 3) #04567) => #04387

" a bignum (-1_32)

For a table of related items: See the section "Summary of Byte Manipula-tion FuncManipula-tions" in Symbolics Common Lisp: Language Concepts.

sys:dynamic-closure Type Specifier

sys:dynamic-closure is the type specifier symbol for the predefined Lisp object of that name.

See the section "Data Types and Type Specifiers" in Symbolics Common Lisp: Language Concepts. See the section "Scoping" in Symbolics Common Lisp: Language Concepts.

Examples:

(setq four (let ((x

(closure '(x) 'zerop») => #<DTP-CLOSURE 1518647>

(typep four 'sys:dynamic-closure) => T

(subtypep 'sys:dynamic-closure 'common) => NIL and NIL

dynamic-closure-alist closure Function

Returns an alist of (symbol. value) pairs describing the bindings which the dynamic closure performs when it is called. This list is not the same one that is actually stored in the closure; that one contains pointers to value cells rather than symbols, and dynamic-closure-alist translates them back to symbols so you can understand them. As a result, clobbering part of this list does not change the closure.

If any variable in the closure is unbound, this function signals an error.

See the section "Dynamic Closure-Manipulating Functions" in Symbolics Common Lisp: Language Concepts.

dynamic-closure-variables closure Function

Creates and returns a list of all of the variables in the dynamic closure closure. It returns a copy of the list that was passed as the first argument to make-dynamic-closure when closure was created. See the section

"Dynamic Closure-Manipulating Functions" in Symbolics Common Lisp:

Language Concepts.

I

I

ecase

194

ecase object &body body Special Form

The name of this function stands for "exhaustive case" or "error-checking case".

Structurally ecase is much like case, and it behaves like case in selecting one clause and then executing all consequents of that clause. However, ecase does not permit an explicit otherwise or t clause. The form of ecase is as follows:

(ecase key-form

(test consequent consequent ... ) (test consequent consequent ... ) (test consequent consequent ... )

...

)

The first thing ecase does is to evaluate object, to produce an object called the key object.

Then ecase considers each of the clauses in turn. If key is eql to any item in the clause, ecase evaluates the consequents of that clause as an implicit progn.

ecase returns the value of the last consequent of the clause evaluated, or nil if there are no consequents to that clause.

The keys in the clauses are not evaluated; literal key values must appear in the clauses. It is an error for the same key to appear in more than one clause. The order of the clauses does not affect the behavior of the ecase construct.

If there is only one key for a clause, that key can be written in place of ~

list of that key, provided that no ambiguity results. Such a "singleton key"

can not be nil (which is confusable with 0, a list of no keys), t, otherwise, or a cons.

If no clause is satisfied, ecase uses an implicit otherwise clause to signal an error with a message constructed from the clauses. It is not permis-sible to continue from this error. To supply your own error message, use case with an otherwise clause containing a call to error.

Examples:

(1 et ((num 24»

(ecase num

((1 2 3) "integer")

((4 5 6) "integer"») => non-proceedable error is signalled

195

eighth

(let «num 3»

(ecase num

«1 2) "one two")

«3 4 5 6) (princ "numbers") (princ " three") (terpri) ) (t "not today"») => numbers three

T

(let «Dwarf 'Sleepy»

(ecase Dwarf

«Grumpy Dopey) (setq class "confused"»

«Bilbo Frodo) (setq class "Hobbits not Dwarfs"»

(otherwise (setq class 'unknown) "talk to Snow White"»)

=> "talk to Snow White"

class => UNKNOWN (defun test-ecase (x)

(ecase x

(a I a) (b 'b)

(otherwise 'c») => TEST-ECASE (test-ecase 'd) => C

For a table of related items: See the section "Conditional Functions II in Symbolics Common Lisp: Language Concepts.

For a table of related items: See the section "Condition-Checking and Sig-nalling Functions and Variables" in Symbolics Common Lisp: Language Concepts.

eighth list Function

eighth takes a list as an argument, and returns the eighth element of list.

eighth is identical to (nth 7 list)

This function is provided because it makes more sense than using nth when you are thinking of the argument as a list rather than just as a cons.

For a table of related items: See the section "Functions for Extracting From Lists" in Symbolics Common Lisp: Language Concepts.

elt sequence index Function

elt returns the element of sequence specified by index.

sequence can be either a list or a vector (one-dimensional array). Note that nil is considered to be a sequence, of length zero.

index must be a non-negative integer less than the length of sequence as returned by length. The first element of a sequence has index

o.

I

I

si :encapsulate

For example:

(setq bird-list '(heron stork pelican turkey» =>

(HERON STORK PELICAN TURKEY) (elt bird-list 2) => PELICAN

(equalp (elt bird-list' 2) (third bird-list» => T

196

Note that elt observes the fill pointer in those vectors that have fill

pointers. The array-specific function aref may be used to access vector ele-ments that are beyond the vector's flll pointer.

setf can be used with elt to destructively replace a sequence element with a new value. For example:

(setf (elt bird-list 2) 'hawk) => HAWK bird-list => (HERON STORK HAWK TURKEY)

For a table of related items: See the section "Sequence Construction and Access" in Symbolics Common Lisp: Language Concepts.

:empty-p of si:heap Method

Returns t if the heap is empty, otherwise returns nil.

For a table of related items: See the section "Heap Functions and Methods"

in Symbolics Common Lisp: Language Concepts.

si:encapsulate function outer-function type body &optional extra-debugging-info

A call to si:encapsulate looks like:

(si : encapsul ate function-spec outer-function type body-form

extra-debugging-info)

Macro

All the subforms of this macro are evaluated. In fact, the macro could al-most be replaced with an ordinary function, except for the way body-form is handled.

function-spec evaluates to the function spec whose defmition the new encap-sulation should become. outer-function is another function spec, which should often be the same one. Its only purpose is to be used in any error messages from si:encapsulate.

type evaluates to a symbol that identifles the purpose of the encapsulation;

it says what the application is. For example, it could be advise or trace.

The list of possible types is deflned by the system because encapsulations are supposed to be kept in an order according to their type. See the

vari-197

si:encapsulate

able si:encapsulation-standard-order, page 198. type should have an si:encapsulation-grind-function property that tells grindef what to do with an encapsulation of this type.

body-form is a form that evaluates to the body of the

encapsulation-definition, the code to be executed when it is called. Backquote is typically used for this expression. See the section "Backquote" in Symbolics Com-mon Lisp: Language Concepts. si:encapsulate is a macro because, while body is being evaluated, the variable si:encapsulated-function is bound to a list of the form (function uninterned-symbol), referring to the uninterned symbol used to hold the prior definition of function-spec. If si:encapsulate were a function, body-form would just get evaluated normally by the

evaluator before si:encapsulate ever got invoked, and so there would be no opportunity to bind si:encapsulated-function. The form body-form should contain (apply si:encapsulated-function arglist) somewhere if the encap-sulation is to live up to its name and truly serve to encapsulate the

original definition. (The variable arglist is bound by some of the code that the si:encapsulate macro produces automatically. When the body of the encapsulation is run, arglist's value is the list of the arguments that the encapsulation received.)

extra-debugging-info evaluates to a list of extra items to put into the debug-ging info alist of the encapsulation function (besides the one starting with si:encapsulated-definition that every encapsulation must have). Some ap-plications find this useful for recording information about the encapsulation for their own later use.

When a special function is encapsulated, the encapsulation is itself a spe-cial function with the same argument quoting pattern. (Not all quoting patterns can be handled; if a particular special form's quoting pattern can-not be handled, si:encapsulate signals an error.) Therefore, when the out-ermost encapsulation is started, each argument has been evaluated or not as appropriate. Because each encapsulation calls the prior definition with apply, no further evaluation takes place, and the basic definition of the special form also finds the arguments evaluated or not as appropriate. The basic definition can call eval on some of these arguments or parts of them;

the encapsulations should not.

Macros cannot be encapsulated, but their expander functions can be; if the definition of function-spec is a macro, then si:encapsulate automatically en-capsulates the expander function instead. In this case, the definition of the uninterned symbol is the original macro definition, not just the original ex-pander function. It would not work for the encapsulation to apply the macro definition. So during the evaluation of body-form,

si:encapsulated-function is bound to the form (cdr (function

uninterned-symbol», which extracts the expander function from the prior definition of the macro.

I

Dans le document Symbolics Common Lisp: Language Dictionary (Page 196-200)