This section describes the additions features in EULISP level-1 including the reflective aspects of the object system and how to program the metaobject protocol and support for dynamic variable and related control forms.
defmodule-1-form: |
( defmodule module-name |
module-directives |
level-1-module-form* ) |
level-1-module-form: |
level-0-module-form |
level-1-form |
defining-1-form |
level-1-form: |
level-0-form |
special-1-form |
form: |
level-1-form |
special-form: |
special-1-form |
defining-1-form: |
defclass-1-form |
defgeneric-1-form |
defglobal-form |
special-1-form: |
generic-lambda-form |
method-lambda-form |
defmethod-form |
?? |
catch-form |
throw-form |
defclass-1-form: |
( defclass class-name superclass-names |
( slot-1* ) |
class-option-1* ) |
superclass-names: |
() |
superclass-name |
( superclass-name* ) |
slot-1: |
slot |
( slot-name slot-option-1* ) |
slot-option-1: |
slot-option |
identifier level-1-form |
class-option-1 |
class-option |
class: class-name |
identifier level-1-form |
Either a symbol or a list of symbols naming bindings of the class/classes to be used as the superclass/superclasses of the new class (multiple inheritance). If this list of superclass names is empty, the superclass is <object>. This is different from defclass at level-0, where only one superclass may be specified.
A list of slot specifications (see below), comprising either a slot-name or a list of a slot-name followed by some slot-options. One of the class options (see below) allows the specification of the class of the slot description.
A key and a value (see below). One of the class options (<class>) allows the specification of the class of the class being defined.
This defining form defines a new class. The resulting class will be bound to class-name. All the slot and class options are exactly the same as for defclass (11.3.1).
The slot-option-1s are interpreted as follows:
The class-option-1s are interpreted as follows:
generic-lambda-form: |
( generic-lambda gf-lambda-list |
level-1-init-option* ) |
level-1-init-option: |
class class-name |
method-class class-name |
method level-1-method-description |
identifier level-1-form |
level-0-init-option |
level-1-method-description: |
( method-init-option* |
specialized-lambda-list |
body ) |
method-init-option: |
class class-name |
identifier level-1-form |
As level-0. See section 11.4.5.
Format as level-0, but with additional options, which are defined below.
A generic function.
The syntax of generic-lambda is an extension of the level-0 syntax allowing additional init-options. These allow the specification of the class of the new generic function, which defaults to <generic-function>, the class of all methods, which defaults to <method>, and non-standard options. The latter are evaluated in the lexical and dynamic environment of generic-lambda and passed to make of the generic function as additional initialization arguments. The additional init-options over level-0 are interpreted as follows:
In addition, method init options can be specified for the individual methods on a generic function. These are interpreted as follows:
In the following example an anonymous version of gf-1 (see defgeneric) is defined. In all other respects the resulting object is the same as gf-1.
As level-0. See section 11.4.5.
As level-0. See section 11.4.5.
As for generic-lambda, defined above. below.
This defining form defines a new generic function. The resulting generic function will be bound to gf-name. The second argument is the formal parameter list. An error is signalled (condition: <non-congruent-lambda-lists> ) if any of the methods defined on this generic function do not have lambda lists congruent to that of the generic function. This applies both to methods defined at the same time as the generic function and to any methods added subsequently by defmethod or add-method. An init-option is a identifier followed by its initial value. The syntax of defgeneric is an extension of the level-0 syntax. The rewrite rules for the defgeneric form are identical to those given in section 11.4.5.2 except that level 1 init option replaces level 0 init option.
In the following example of the use of defgeneric a generic function named gf-1 is defined. The differences between this function and gf-0 (see 11.4.5) are
A quoted symbol followed by an expression.
As defined under generic-lambda.
An expression.
This syntax creates and returns an anonymous method with the given lambda list and body. This anonymous method can later be added to a generic function with a congruent lambda list via the generic function add-method. Note that the lambda list can be specialized to specify the method’s domain. The value of the special keywords <class> determines the class to instantiate; the rest of the initlist is passed to make called with this class. The default method class is <method>.
The additional method-init-options includes <class>, for specifying the class of the method to be defined, and non-standard options, which are evaluated in the lexical and dynamic environment of method-lambda and passed to initialize of that method.
The defmethod form of level-1 extends that of level-0 to accept method-init-options. This allows for the specification of the method class by means of the <class> init option. This class must be a subclass of the method class of the host generic function. The method class otherwise defaults to that of the host generic function. In all other respects, the behaviour is as that defined in level-0.
A lambda list
A sequence of forms.
This syntax operator creates and returns an anonymous method function with the given lambda list and body. This anonymous method function can later be added to a method using method-function, or as the function initialization value in a call of make on an instance of <method>. A function of this type is also returned by the method accessor method-function. Only functions created using this syntax operator can be used as method functions. Note that the lambda list must not be specialized; a method’s domain is stored in the method itself.
A method.
A list of methods.
A sequence of expressions.
This function calls the method method with arguments args. The argument next-methods is a list of methods which are used as the applicable method list for args; it is an error if this list is different from the methods which would be produced by the method lookup function of the generic function of method. If method is not attached to a generic function, its behavior is unspecified. The next-methods are used to determine the next method to call when call-next-method is called within method-fn.
A method.
A list of methods.
A sequence of expressions.
An expression.
This function is identical to call-method except that its last argument is a list whose elements are the other arguments to pass to the method’s method function. The difference is the same as that between normal function application and apply.
An object.
The class of the object.
The function class-of can take any LISP object as argument and returns an instance of <class> representing the class of that entity.
The minimum information associated with a class metaobject is:
Standard classes support local slots only. Shared slots can be provided by extensions. The minimal information associated with a slot description metaobject is:
The metaobject classes defined for slot descriptions at level-1 are shown in table 6.
<object> See level-0 table 1 |
<slot> |
<local-slot> |
<function> |
<generic-function> |
<simple-generic-function> |
<method> |
<simple-method> |
Place holder for <metaclass>.
Place holder for <simple-class>.
Place holder for <function-class>.
A class.
Returns a string which is binary= <string> to that given as the argument to the call to ?? which created class. It is an error to modify this string.
A class.
A list of classes, starting with class itself, succeeded by the superclasses of class and ending with <object>. This list is equivalent to the result of calling ??.
The class precedence list is used to control the inheritance of slots and methods.
A class.
A list of slots, one for each of the slots of an instance of class.
The slots determine the instance size (number of slots) and the slot access.
A class.
A list of symbols, which can be used as legal keywords to initialize instances of the class.
The keywords correspond to the keywords specified in the keyword slot-option or the keywords class-option when the class and its superclasses were defined.
The abstract class of all slot descriptions.
The class of all local slot descriptions.
The default value for all initoptions is ().
A slot description.
The symbol which was used to name the slot when the class, of which the slot is part, was defined.
The slot description name is used to identify a slot description in a class. It has no effect on bindings.
A slot description.
A function of no arguments that is used to compute the initial value of the slot in the absence of a supplied value.
A slot description.
A function of one argument that returns the value of the slot in that argument.
A slot description.
A function of two arguments that installs the second argument as the value of the slot in the first argument.
The minimum information associated with a generic function metaobject is:
A generic function.
A list of classes.
This function returns the domain of a generic function. The domains of all methods attached to a generic function are constrained to be within this domain. In other words, the domain classes of each method must be subclasses of the corresponding generic function domain class. It is an error to modify this list.
A generic function.
This function returns the class which is the class of all methods of the generic function. Each method attached to a generic function must be an instance of this class. When a method is created using defmethod, method-lambda, or by using the method generic function option in a defgeneric or generic-lambda, it will be an instance of this class by default.
A generic function.
This function returns a list of the methods attached to the generic function. The order of the methods in this list is undefined. It is an error to modify this list.
A generic function.
A function.
This function returns a function which, when applied to the arguments given to the generic function, returns a sorted list of applicable methods. The order of the methods in this list is determined by compute-method-lookup-function.
A generic function.
A function.
This function returns a function which may be applied to the same arguments as the generic function. This function is called to perform the generic dispatch operation to determine the applicable methods whenever the generic function is called, and call the most specific applicable method function. This function is created by compute-discriminating-function.
The metaobject classes for generic functions defined at level-1 are shown in table 6.
Place holder for <method>.
Place holder for ??.
A method.
A list of classes defining the domain of a method.
A method.
This function returns a function which implements the method. The returned function which is called when method is called, either by calling the generic function with appropriate arguments, through a call-next-method, or by using call-method. A method metaobject itself cannot be applied or called as a function.
A method.
A function.
This function sets the function which implements the method.
A method.
This function returns the generic function to which method is attached; if method is not attached to a generic function, it returns ().
A class.
A list of initialization options as follows:
The initialized class.
The initialization of a class takes place as follows:
The basic call structure is laid out in figure 7
compatible-superclasses? |
cl direct-superclasses → boolean |
compatible-superclass? |
cl superclass → boolean |
compute-class-precedence-list |
cl direct-superclasses → (cl*) |
compute-inherited-keywords |
cl direct-superclasses → ((keyword*)*) |
compute-keywords |
cl direct-keywords inherited-keywords |
→ (keyword*) |
compute-inherited-slots |
cl direct-superclasses → ((sd*)*) |
compute-slots |
cl slot-specs inherited-sds → (sd*) |
either |
compute-defined-slot |
cl slot-spec → sd |
compute-defined-slot-description-class |
cl slot-spec → sd-class |
or |
compute-specialized-slot |
cl inherited-sds slot-spec → sd |
compute-specialized-slot-class |
cl inherited-sds slot-spec |
→ sd-class |
compute-instance-size |
cl effective-sds → integer |
compute-and-ensure-slot-accessors |
cl effective-sds inherited-sds → (sd*) |
compute-slot-reader |
cl sd effective-sds → function |
compute-slot-writer |
cl sd effective-sds → function |
ensure-slot-reader |
cl sd effective-sds reader → function |
compute-primitive-reader-using-slot |
sd cl effective-sds → function |
compute-primitive-reader-using-class |
cl sd effective-sds → function |
ensure-slot-writer |
cl sd effective-sds writer → function |
compute-primitive-writer-using-slot |
sd cl effective-sds → function |
compute-primitive-writer-using-class |
cl sd effective-sds → function |
Note that compute-keywords is called by the default initialize method with all direct keywords as the second argument: those specified as slot option and those specified as class option.
A class.
Computes and returns a function of one argument, which is a predicate function for class.
A class.
Computes and returns a function of one argument, which returns t when applied to direct or indirect instances of class and () otherwise.
A class.
The argument list of the function being created.
Computes and returns a constructor function for class.
A class.
The argument list of the function being created.
Computes and returns a constructor function, which returns a new instance of class.
A class.
A list of initialization arguments.
An instance of the first argument.
Creates an instance of the first argument. Users may define new methods for new metaclasses.
A class.
A list of initialization arguments.
An instance of the first argument.
The default method creates a new uninitialized instance of the first argument. The initlist is not used by this allocate method.
A slot description.
A list of initialization options as follows:
The initialized slot description.
A generic function.
A list of initialization options as follows:
The initialized generic function.
This method initializes and returns the generic-function. The specified methods are attached to the generic function by add-method, and its slots are initialized from the information passed in initlist and from the results of calling compute-method-lookup-function and compute-discriminating-function on the generic function. Note that these two functions may not be called during the call to initialize, and that they may be called several times for the generic function.
The basic call structure is: add-method gf method -> gf
compute-method-lookup-function gf domain -> function
compute-discriminating-function gf domain lookup-fn
methods -> function
A method.
A list of initialization options as follows:
This method returns the initialized method metaobject method. If the generic-function option is supplied, add-method is called to install the new method in the generic-function.
A class.
A list of potential direct superclasses of class.
Returns t if class is compatible with direct-superclasses, otherwise ().
A class.
A list of potential direct superclasses.
Returns the result of calling compatible-superclass? on class and the first element of the direct-superclasses (single inheritance assumption).
A class.
A potential direct superclass.
Returns t if subclass is compatible with superclass, otherwise ().
A class.
A potential direct superclass.
Returns t if the class of the first argument is a subclass of the class of the second argument, otherwise ().
If the implementation wishes to restrict the instantiation tree (see introduction to B.4), this method should return () if superclass is <metaclass>.
A class.
A potential direct superclass.
Always returns t.
A class.
A potential direct superclass.
Always returns ().
A class.
A potential direct superclass.
Always returns t.
Class being defined.
List of direct superclasses.
Computes and returns a list of classes which represents the linearized inheritance hierarchy of class and the given list of direct superclasses, beginning with class and ending with <object>.
Class being defined.
List of direct superclasses.
A list of classes.
This method can be considered to return a cons of class and the class precedence list of the first element of direct-superclasses (single inheritance assumption). If no direct-superclasses has been supplied, the result is the list of two elements: class and <object>.
Class being defined.
A list of direct slot specification.
A list of lists of inherited slot descriptions.
Computes and returns the list of effective slot descriptions of class.
Class being defined.
List of (direct) slot specifications.
A list of lists (in fact one list in single inheritance) of inherited slot descriptions.
A list of effective slot descriptions.
The default method computes two sublists:
The method returns the concatenation of these two lists as its result. The order of elements in the list is significant. All specialized slot descriptions have the same position as in the effective slot descriptions list of the direct superclass (due to the single inheritance). The slot accessors (computed later) may rely on this assumption minimizing the number of methods to one for all subclasses and minimizing the access time to an indexed reference.
compute-specialized-slot, compute-defined-slot, compute-and-ensure-slot-accessors.
Class being defined.
List of direct keywords.
A list of lists of inherited keywords.
List of symbols.
Computes and returns all legal keywords for class.
Class being defined.
List of direct keywords.
A list of lists of inherited keywords.
List of symbols.
This method appends the second argument with the first element of the third argument (single inheritance assumption), removes duplicates and returns the result. Note that compute-keywords is called by the default initialize method with all direct keywords as the second argument: those specified as slot option and those specified as class option.
Class being defined.
List of direct superclasses.
List of lists of inherited slot descriptions.
Computes and returns a list of lists of effective slot descriptions.
Class being defined.
List of direct superclasses.
List of lists of inherited slot descriptions.
The result of the default method is a list of one element: a list of effective slot descriptions of the first element of the second argument (single inheritance assumption). Its result is used by compute-slots as an argument.
Class being defined.
List of direct superclasses.
List of lists of symbols.
Computes and returns a list of lists of keywords. Its result is used by compute-keywords as an argument.
Class being defined.
List of direct superclasses.
List of lists of symbols.
The result of the default method contains one list of legal keywords of the first element of the second argument (single inheritance assumption).
Class being defined.
Canonicalized slot specification.
Slot description.
Computes and returns a new effective slot description. It is called by compute-slots on each slot specification which has no corresponding inherited slot descriptions.
Class being defined.
Canonicalized slot specification.
Slot description.
Computes and returns a new effective slot description. The class of the result is determined by calling compute-defined-slot-class.
Class being defined.
Canonicalized slot specification.
Slot description class.
Determines and returns the slot description class corresponding to class and slot-spec .
Class being defined.
Canonicalized slot specification.
The class <local-slot>.
This method just returns the class <local-slot>.
Class being defined.
List of inherited slot descriptions (each of the same name as the slot being defined).
Canonicalized slot specification or ().
Slot description.
Computes and returns a new effective slot description. It is called by compute-slots on the class, each list of inherited slots with the same name and with the specialising slot specification list or () if no one is specified with the same name.
compute-specialized-slot-class.
Class being defined.
List of inherited slot descriptions.
Canonicalized sdirect-lot specification or ().
Slot description.
Computes and returns a new effective slot description. The class of the result is determined by calling compute-specialized-slot-class.
compute-specialized-slot-class.
Class being defined.
List of inherited slot descriptions.
Canonicalized slot specification or ().
Slot description class.
Determines and returns the slot description class corresponding to (i) the class being defined, (ii) the inherited slot descriptions being specialized (iii) the specializing information in slot-spec.
Class being defined.
List of inherited slot descriptions.
Canonicalized slot specification or ().
The class <local-slot>.
This method just returns the class <local-slot>.
Each slot has exactly one reader and one writer as anonymous objects. If a reader/writer slot-option is specified in a class definition, the anonymous reader/writer of that slot is bound to the specified identifier. Thus, if a reader/writer option is specified more than once, the same object is bound to all the identifiers. If the accessor slot-option is specified the anonymous writer will be installed as the setter of the reader. Specialized slots refer to the same objects as those in the superclasses (single inheritance makes that possible). Since the readers/writers are generic, it is possible for a subclass (at the meta-level) to add new methods for inherited slots in order to make the readers/writers applicable on instances of the subclass. A new method might be necessary if the subclasses have a different instance allocation or if the slot positions cannot be kept the same as in the superclass (in multiple inheritance extensions). This can be done during the initialization computations.
Class being defined.
List of effective slot descriptions.
List of lists of inherited slot descriptions.
List of effective slot descriptions.
Computes new accessors or ensures that inherited accessors work correctly for each effective slot description.
Class being defined.
List of effective slot descriptions.
List of lists of inherited slot descriptions.
List of effective slot descriptions.
For each slot description in slots the default method checks if it is a new slot description and not an inherited one. If the slot description is new,
Otherwise, it assumes that the inherited values remain valid.
Finally, for every slot description (new or inherited) it ensures the reader and writer work correctly on instances of class by means of ensure-slot-reader and ensure-slot-writer.
Class.
Slot description.
List of effective slot descriptions.
Function.
Computes and returns a new slot reader applicable to instances of class returning the slot value corresponding to slot. The third argument can be used in order to compute the logical slot position.
Class.
Slot description.
List of effective slot descriptions.
Generic function.
The default method returns a new generic function of one argument without any methods. Its domain is class.
Class.
Slot description.
List of effective slot descriptions.
Function.
Computes and returns a new slot writer applicable to instances of class and any value to be stored as the new slot value corresponding to slot. The third argument can be used in order to compute the logical slot position.
Class.
Slot description.
List of effective slot descriptions.
Generic function.
The default method returns a new generic function of two arguments without any methods. Its domain is class ×<object>.
Class.
Slot description.
List of effective slot descriptions.
The slot reader.
Function.
Ensures function correctly fetches the value of the slot from instances of class.
Class.
Slot description.
List of effective slot descriptions.
The slot reader.
Generic function.
The default method checks if there is a method in the generic-function. If not, it creates and adds a new one, otherwise it assumes that the existing method works correctly. The domain of the new method is class and the function is
(method-function-lambda ((object class)) |
(primitive-reader object)) |
compute-primitive-reader-using-slot is called by ensure-slot-reader method to compute the primitive reader used in the function of the new created reader method.
Class.
Slot description.
List of effective slot descriptions.
The slot writer.
Function.
Ensures function correctly updates the value of the slot in instances of class.
Class.
Slot description.
List of effective slot descriptions.
The slot writer.
Generic function.
The default method checks if there is a method in the generic-function. If not, creates and adds a new one, otherwise it assumes that the existing method works correctly. The domain of the new method is class ×<object> and the function is:
(method-function-lambda ((obj class) |
(new-value <object>)) |
(primitive-writer obj new-value)) |
compute-primitive-writer-using-slot is called by ensure-slot-writer method to compute the primitive writer used in the function of the new created writer method.
Slot description.
Class.
List of effective slot descriptions.
Function.
Computes and returns a function which returns a slot value when applied to an instance of class.
Slot description.
Class.
List of effective slot descriptions.
Function.
Calls compute-primitive-reader-using-class. This is the default method.
Class.
Slot description.
List of effective slot descriptions.
Function.
Computes and returns a function which returns the slot value when applied to an instance of class.
Class.
Slot description.
List of effective slot descriptions.
Function.
The default method returns a function of one argument.
Slot description.
Class.
List of effective slot descriptions.
Function.
Computes and returns a function which stores a new slot value when applied on an instance of class and a new value.
Slot description.
Class.
List of effective slot descriptions.
Function.
Calls compute-primitive-writer-using-class. This is the default method.
Class.
Slot description.
List of effective slot descriptions.
Function.
Computes and returns a function which stores the new slot value when applied on an instance of class and new value.
Class.
Slot description.
List of effective slot descriptions.
Function.
The default method returns a function of two arguments.
A generic function.
A list of classes which cover the domain.
A function.
Computes and returns a function which will be called at least once for each domain to select and sort the applicable methods by the default dispatch mechanism. New methods may be defined for this function to implement different method lookup strategies. Although only one method lookup function generating method is provided by the system, each generic function has its own specific lookup function which may vary from generic function to generic function.
A generic function.
A list of classes which cover the domain.
A function.
Computes and returns a function which will be called at least once for each domain to select and sort the applicable methods by the default dispatch mechanism. It is not defined, whether each generic function may have its own lookup function.
A generic function.
A list of classes which span the domain.
The method lookup function.
A list of methods attached to the generic-function.
A function.
This generic function computes and returns a function which is called whenever the generic function is called. The returned function controls the generic dispatch. Users may define methods on this function for new generic function classes to implement non-default dispatch strategies.
A generic function.
A list of classes which span the domain.
The method lookup function.
A list of methods attached to the generic-function.
A function.
This method computes and returns a function which is called whenever the generic function is called. This default method implements the standard dispatch strategy: The generic function’s methods are sorted using the function returned by compute-method-lookup-function, and the first is called as if by call-method, passing the others as the list of next methods. Note that call-method need not be directly called.
A generic function.
A method to be attached to the generic function.
This generic function adds method to the generic function gf. This method will then be taken into account when gf is called with appropriate arguments. It returns the generic function gf. New methods may be defined on this generic function for new generic function and method classes.
In contrast to CLOS, add-method does not remove a method with the same domain as the method being added. Instead, a noncontinuable error is signalled.
A generic function.
A method to be attached.
The generic function.
This method checks that the domain classes of the method are subclasses of those of the generic function, and that the method is an instance of the generic function’s method class. If not, signals an error (condition: ?? ). It also checks if there is a method with the same domain already attached to the generic function. If so, a noncontinuable error is signaled (condition: <method-domain-clash> ). If no error occurs, the method is added to the generic function. Depending on particular optimizations of the generic dispatch, adding a method may cause some updating computations, e.g. by calling compute-method-lookup-function and compute-discriminating-function.
A class.
An integer.
An instance of the first argument.
This function returns a new instance of the first argument which has a vector-like structure of length size. The components of the new instance can be accessed using primitive-ref and updated using primitive-ref. It is intended to be used in new allocate methods defined for new metaclasses.
An object created by primitive-allocate.
A class.
This function returns the class of an object. It is similar to class-of, which has a defined behaviour on any object. It is an error to use primitive-class-of on objects which were not created by primitive-allocate.
An object created by primitive-allocate.
A class.
The class.
This function supports portable implementations of
An object created by primitive-allocate.
The index of a component.
An object.
Returns the value of the objects component corresponding to the supplied index. It is an error if index is outside the index range of object. This function is intended to be used when defining new kinds of accessors for new metaclasses.
An object created by primitive-allocate.
The index of a component.
The new value, which can be any object.
The new value.
Stores and returns the new value as the objects component corresponding to the supplied index. It is an error if index is outside the index range of object. This function is intended to be used when defining new kinds of accessors for new metaclasses.
dynamic-form: → <object> |
( dynamic identifier ) |
A symbol naming a dynamic binding.
The value of closest dynamic binding of identifier is returned. If no visible binding exists, an error is signaled (condition: <unbound-dynamic-variable> ).
dynamic-setq-form: → <object> |
( dynamic-setq identifier form ) |
A symbol naming a dynamic binding to be updated.
An expression whose value will be stored in the dynamic binding of identifier.
The value of form.
The form is evaluated and the result is stored in the closest dynamic binding of identifier. If no visible binding exists, an error is signalled (condition: <unbound-dynamic-variable> ).
Signalled by dynamic or dynamic-setq if the given dynamic variable has no visible dynamic binding.
A list of binding specifiers.
A sequence of forms.
The sequence of forms is evaluated in order, returning the value of the last one as the result of the dynamic-let form.
A binding specifier is either an identifier or a two element list of an identifier and an initializing form. All the initializing forms are evaluated from left to right in the current environment and the new bindings for the symbols named by the identifiers are created in the dynamic environment to hold the results. These bindings have dynamic scope and dynamic extent . Each form in body is evaluated in order in the environment extended by the above bindings. The result of evaluating the last form in body is returned as the result of dynamic-let.
defglobal-form: → <object> |
( defglobal identifier level-1-form ) |
A symbol naming a top dynamic binding containing the value of form.
The form whose value will be stored in the top dynamic binding of identifier.
The value of form is stored as the top dynamic value of the symbol named by identifier . The binding created by defglobal is mutable. An error is signaled (condition: <dynamic-multiply-defined> ), on processing this form more than once for the same identifier.
Signalled by defglobal if the named dynamic variable already exists.
The catch operator is similar to block, except that the scope of the name (tag) of the exit function is dynamic. The catch tag must be a symbol because it is used as a dynamic variable to create a dynamically scoped binding of tag to the continuation of the catch form. The continuation can be invoked anywhere within the dynamic extent of the catch form by using throw. The forms are evaluated in sequence and the value of the last one is returned as the value of the catch form.
Exiting from a catch, by whatever means, causes the restoration of the lexical environment and dynamic environment that existed before the catch was entered. The above rewrite for catch, causes the variable tmp to be shadowed. This is an artifact of the above presentation only and a conforming processor must not shadow any variables that could occur in the body of catch in this way.
In throw, the tag names the continuation of the catch from which to return. throw is the invocation of the continuation of the catch named tag. The body is evaluated and the value are returned as the value of the catch named by tag. The tag is a symbol because it used to access the current dynamic binding of the symbol, which is where the continuation is bound.
Any productions undefined here appear elsewhere in the definition, specifically: the syntax of most expressions and definitions is given in the section defining level-0.
defmodule-1-form: |
( defmodule module-name |
module-directives |
level-1-module-form* ) |
level-1-module-form: |
level-0-module-form |
level-1-form |
defining-1-form |
level-1-form: |
level-0-form |
special-1-form |
form: |
level-1-form |
special-form: |
special-1-form |
defining-1-form: |
defclass-1-form |
defgeneric-1-form |
defglobal-form |
special-1-form: |
generic-lambda-form |
method-lambda-form |
defmethod-form |
?? |
catch-form |
throw-form |
defclass-1-form: |
( defclass class-name superclass-names |
( slot-1* ) |
class-option-1* ) |
superclass-names: |
() |
superclass-name |
( superclass-name* ) |
slot-1: |
slot |
( slot-name slot-option-1* ) |
slot-option-1: |
slot-option |
identifier level-1-form |
class-option-1 |
class-option |
class: class-name |
identifier level-1-form |
dynamic-form: → <object> |
( dynamic identifier ) |
generic-lambda-form: |
( generic-lambda gf-lambda-list |
level-1-init-option* ) |
level-1-init-option: |
class class-name |
method-class class-name |
method level-1-method-description |
identifier level-1-form |
level-0-init-option |
level-1-method-description: |
( method-init-option* |
specialized-lambda-list |
body ) |
method-init-option: |
class class-name |
identifier level-1-form |
throw-form: → <object> |
( throw tag body ) |