add-member! | (add-member! object field-name field-value) | Add a new member (data or function) to an object by mutation. |
apply-function | (apply-function function-object actual-parameter-list) | Apply the function object on the given actual parmeters. |
as-independent-object! | (as-independent-object! object) | Disconnect an object with class from its class, and transfer the methods from the class to the object. |
as-instance-of-class! | (as-instance-of-class! object class) | Mutate object be to an instance of class. |
asl-object? | (asl-object? x) | Is x an object. |
class-object | class-object | The implicit superclass of all classes. |
class-of | (class-of obj) | Return the class object of object, or #f if obj is not an instance of a class object. |
class-source | (class-source class-object class-name superclass-name file-path [role]) | Generate a string with the class source form on a file. |
clone-object | (clone-object obj . initializer-fields) | Make a shallow copy of obj, and re-assign the field values of the copy as prescribed by initializer-fields |
delete-member! | (delete-member! object field-name) | Delete an existing member (data or method) from an object, by mutation of object. |
environment-of-function | (environment-of-function function) | The environment of a function. |
eval-expr | (eval-exr expr env) | Evaluate the expression expr in the environment env. |
expression-of-function | (expression-of-function function) | The expression of a function. |
formal-parameters-of-function | (formal-parameters-of-function function) | The formal parameters of a function. |
function | (function formal-parameters body-form ...) | Make and return a function object with the given formal parameter list and a given body. |
function? | (function? x) | Is x a function? |
generalize | (generalize class-list member-names) | Return a new class which generalizes all classes in class-list. |
get-field | (get-field object field-name) | Get the value of a named field in an object. |
inspect | (inspect object [variation]) | Prints useful information about object. |
instance-of? | (instance-of? object class) | Is object an instance of class. |
kappa | (kappa . objects) | Infer the class of the objects, and return the object that represents the class. |
kappa? | (kappa? x) | Is x a class object? |
make-class | (make-class [superclass] [field-name field-value]...) | Make a class-object with a given superclass and given fields. |
make-object | (make-object [object-role-name] [field-name field-value]...) | A operation that makes an object with given fields, either as an independent object or as an instance of a class (in case the role asked for is mapped to a class). |
new-object | (new class-object [field-name field-value]...) | Make a new object as an instance of a class, as represented by class-object. |
object-role | (object-role object) | Return the role of object. |
object-with-class? | (object-with-class? x) | Is x an object, which is an instance of some class. |
object-without-class? | (object-without-class? x) | Is x an object, which is not an instance of some class. |
root-object | root-object | The root class in the system. |
send | (send object selector . actual-parameters) | Apply a method in object, as selected by the symbol selector, on the given actual parameters. |
send-super | (send-super object selector . actual-parameters) | Like send, but locates the method 'in a superclass' relative to the receiver. |
set-field! | (set-field! object field-name field-value) | In object, set the value of an existing field named field-name to field-value. |
specialize | (specialize class . fields) | Make and return a specialization of class. |
superclass-of | (superclass-of class-obj) | Provided that class-obj is a class object, return the superclass of class-obj. |
1 ASL object and class Primitives. | |||
This section contains the most important object and class related primitives in ASL2. Among these, ASL operations that create objects and classes. | |||
new-object | |||
Form | (new class-object [field-name field-value]...) | ||
Description | Make a new object as an instance of a class, as represented by class-object. The initial values of the fields are taken from the default field values of the class. The default initial field values can be overwritten (by mutation) done on the basis of the remaining parameters. This primitive represents is concretization step. | ||
Parameters | class-object | An object of kind class. | |
field-name | The name of an existing field in the class. | ||
field-value | The new value of field-name in the new object. | ||
See also | Scheme source file | new-object | |
Note | In version 2 this primitive was called new. | ||
make-object | |||
Form | (make-object [object-role-name] [field-name field-value]...) | ||
Description | A operation that makes an object with given fields, either as an independent object or as an instance of a class (in case the role asked for is mapped to a class). The object role name is an optional string, which indicates the user's intention. If the object role name is provided (as string), we organize the objects by their role in an association list keyed by the object role string. | ||
Parameters | fields | The fields given as a property list. | |
object-role-name. | An informal object role name, such as the perceived type of the object. All objects with the same role name are collected in ... A string. | ||
field-name. | A symbol. | ||
field-valued. | Of arbitrary type. | ||
Returns | An object. | ||
See also | Scheme source file | make-object | |
Note | field-names prefixed with a dollar character, such as $kind and $superclass, are used for internal book-keeping purposes. | ||
make-class | |||
Form | (make-class [superclass] [field-name field-value]...) | ||
Description | Make a class-object with a given superclass and given fields. This primtive represents a concretization step rather than an abstraction step, because it makes a more special class from a general class. The value of given fields of in class serve as default field values when the class is instantiated. As an alternative to use of make-class, it is possible to derive a class from an object with use of kappa. | ||
Parameters | superclass | An existing superclass object. Defaults to root-object. | |
fields | The fields given as a property list. These fields become default values of forthcoming instances. Defaults to the empty property list. | ||
Returns | An class object. | ||
See also | Scheme source file | make-class | |
Alternative | kappa | ||
Sugared variant | specialize | ||
Note | Internally, a class which does not have a $superclass field is considered a subclass of class root-object. Class root-object is the root class in the system. | ||
kappa | |||
Form | (kappa . objects) | ||
Description | Infer the class of the objects, and return the object that represents the class. It is possible to pass one or more objects as input to kappa. The field values of the first object become default field values of the inferred class. The first object passed to kappa prescribes the fields which must be present in all other objects. As a side effect, all objects passed to kappa become instances of the class (kappa calls as-instance-of! on all objects). As an additional side effect, if all objects possess a unique object role, this object role is mapped to the new class. (This affects the working of make-object). | ||
Precondition | The parameter objects is non-empty. None of the objects represents a class. | ||
Returns | The object which represents the inferred class. | ||
See also | Scheme source file | kappa | |
add-member! | |||
Form | (add-member! object field-name field-value) | ||
Description | Add a new member (data or function) to an object by mutation. Can used on both independent objects, instances of classes and class objects. If field-name already exists in object the old field is removed before the new field is added. add-member! has no return value. | ||
Parameters | object | An object to which we will add a new member | |
field-name | The name of the new member. A symbol. | ||
field-value | The value of the new member. | ||
See also | Scheme source file | add-member! | |
Note | This is a mutating procedure. object is mutated to contain a new field. | ||
delete-member! | |||
Form | (delete-member! object field-name) | ||
Description | Delete an existing member (data or method) from an object, by mutation of object. Can be used on any kind of object. | ||
Parameters | object | An object from which to delete a member. | |
field-name | The name of the member to delete. A symbol. | ||
See also | Scheme source file | delete-member! | |
non mutating counterpart | delete-member | ||
Note | This is a mutating procedure which modifies the state of object. | ||
get-field | |||
Form | (get-field object field-name) | ||
Description | Get the value of a named field in an object. You should only this get-field as a back door accessor. Accessible fields should be accessed via the automatically generated access methods, or lexically (if accessed from inside a method). The function get-field can be used on both independent objects, instances of classes, and class objects. As a special case on instances of classes, take the value from the default value of the class, if it does not exist in the object (first case in the body of this function). If get-field is applied in a function, which is added as a method to an object/class, the special variable this can be passed as first parameter to get-field, in order to read the values of instance variables. | ||
Parameters | object | An object. | |
field-name | The name of a field (a Scheme symbol). | ||
See also | Scheme source file | get-field | |
set-field! | |||
Form | (set-field! object field-name field-value) | ||
Description | In object, set the value of an existing field named field-name to field-value. You should only use set-field! as a low-level back door facility. Values of accessible fields should be set by the automatically generated setter methods, or internally by using set! on the name of an instance varibale. set-field! has no return value. | ||
Parameters | object | An object | |
field-name | A name of a field. (A Scheme symbol). | ||
field-value | The new value of the field named field-name. | ||
See also | Scheme source file | set-field! | |
Note | Mutating. Changes the state of an existing object. | ||
send | |||
Form | (send object selector . actual-parameters) | ||
Description | Apply a method in object, as selected by the symbol selector, on the given actual parameters. A method is a function object, as created by make-function, which has been added as a member to an object or to a class. Take the method from the object if it exists, or from the class of which the object is an instance. Free variables of the function behind the method are bound in the static environment of the function (as provided as part of the function). Access to instance variables (get/set) are provided via the primitives get-field and set-field! The special variable this is fluently bound to object during the act of sending the message. | ||
Parameters | object | The receiving object | |
selector | A name of a function. A symbol. | ||
actual-parameters | A list of actual parameters of the method. | ||
See also | Scheme source file | send | |
getter/setter | get-field set-field! | ||
similar function | send-super | ||
send-super | |||
Form | (send-super object selector . actual-parameters) | ||
Description | Like send, but locates the method 'in a superclass' relative to the receiver. | ||
Parameters | object | The receving object | |
selector | A name of a function, selected in the superclass of the class of object. | ||
actual-parameters | A list of actual parameters of the method. | ||
See also | Scheme source file | send-super | |
similar function | send | ||
clone-object | |||
Form | (clone-object obj . initializer-fields) | ||
Description | Make a shallow copy of obj, and re-assign the field values of the copy as prescribed by initializer-fields | ||
Parameters | obj | An object. | |
initializer-fields | Initializers represented as a property list. | ||
See also | Scheme source file | clone-object | |
as-instance-of-class! | |||
Form | (as-instance-of-class! object class) | ||
Description | Mutate object be to an instance of class. It is required that all members of the object are present in the class. Methods in the object are removed from the object. It is an error if object does not possess all the fields of class. If object already is registered as an instance of class, then object is just returned. | ||
Parameters | object | An object | |
class | A class object | ||
See also | Scheme source file | as-instance-of-class! | |
as-independent-object! | |||
Form | (as-independent-object! object) | ||
Description | Disconnect an object with class from its class, and transfer the methods from the class to the object. If objects is without a class, just return object. | ||
See also | Scheme source file | as-independent-object! | |
generalize | |||
Form | (generalize class-list member-names) | ||
Description | Return a new class which generalizes all classes in class-list. This is an abstraction step. Mutate the existing classes to have the new class as their superclass. Take the default values of non-function fields from the first class in the list. Transfer all methods from all classes in the list. It is not necessary that all members enumerated in member-name are members of all classes in class-list. With this semantics, multiple generalization may lead to definition of new members in some of the subclasses. Methods that belong to more than one subclass are assumed to be equal to each other. (This is not - and cannot - be tested). | ||
Parameters | class-list | A list of class objects. | |
member-names | A list of members (a list of symbols). | ||
See also | Scheme source file | generalize | |
specialize | |||
Form | (specialize class . fields) | ||
Description | Make and return a specialization of class. The class is extended with fields. | ||
Parameters | class | A class object | |
fields | Fields which extends the set of fields in class. Should be provided as a property list. | ||
Returns | The specialized class object. | ||
See also | Scheme source file | specialize | |
similar primitive | make-class | ||
Internal remark | The specialize primitive is really just syntactic suggar of make-class. Notice also that there is no need of a mutating specialize! variant (because the general class does not refer to its specializations). | ||
class-of | |||
Form | (class-of obj) | ||
Description | Return the class object of object, or #f if obj is not an instance of a class object. | ||
Parameters | obj | An object. | |
See also | Scheme source file | class-of | |
superclass-of | |||
Form | (superclass-of class-obj) | ||
Description | Provided that class-obj is a class object, return the superclass of class-obj. If the class does not have an explicit superclass, return Class. | ||
Parameters | class-obj | A class object | |
See also | Scheme source file | superclass-of | |
root-object | root-object | ||
object-role | |||
Form | (object-role object) | ||
Description | Return the role of object. A string. Some objects may have an empty string as role name. Relies on the particular ASL object representation. | ||
See also | Scheme source file | object-role | |
2 ASL Predicates. | |||
A number of predicates which identifies ASL objects and classes relative to other Scheme objects. | |||
asl-object? | |||
Form | (asl-object? x) | ||
Description | Is x an object. | ||
See also | Scheme source file | asl-object? | |
object-without-class? | |||
Form | (object-without-class? x) | ||
Description | Is x an object, which is not an instance of some class. An non-classified or a weakly classified object. | ||
See also | Scheme source file | object-without-class? | |
object-with-class? | |||
Form | (object-with-class? x) | ||
Description | Is x an object, which is an instance of some class. A strongly classified object. | ||
See also | Scheme source file | object-with-class? | |
kappa? | |||
Form | (kappa? x) | ||
Description | Is x a class object? | ||
See also | Scheme source file | kappa? | |
instance-of? | |||
Form | (instance-of? object class) | ||
Description | Is object an instance of class. True if object has all the fields prescribed by class | ||
Parameters | object | An object. | |
class | An object of kind class. | ||
See also | Scheme source file | instance-of? | |
3 Object inspection. | |||
Functions that can be used to inspect (pretty print) an ASL object. | |||
inspect | |||
Form | (inspect object [variation]) | ||
Description | Prints useful information about object. | ||
Parameters | object | An object | |
variation | Either full or short (a symbol). | ||
See also | Scheme source file | inspect | |
4 Function objects. | |||
Function objects form the basis for methods. When a function object is added to an object or a class, it becomes a method in the object. | |||
function | |||
Form | (function formal-parameters body-form ...) | ||
Description | Make and return a function object with the given formal parameter list and a given body. | ||
Parameters | body | An expression or a sequence of statements, represented as S-expressions. | |
formal-parameters | A list of formal parameter names, either a proper list, an improper list, or a symbol. An symbol, or the tail of an improper list is used as a rest parameter (like in Scheme). | ||
See also | Scheme source file | function | |
Note | This is a syntactic abstraction which calls an underlying constructor function, make-function. Therefore formal-parameters and body are not to be quoted. | ||
function? | |||
Form | (function? x) | ||
Description | Is x a function? | ||
See also | Scheme source file | function? | |
expression-of-function | |||
Form | (expression-of-function function) | ||
Description | The expression of a function. | ||
See also | Scheme source file | expression-of-function | |
formal-parameters-of-function | |||
Form | (formal-parameters-of-function function) | ||
Description | The formal parameters of a function. | ||
See also | Scheme source file | formal-parameters-of-function | |
environment-of-function | |||
Form | (environment-of-function function) | ||
Description | The environment of a function. | ||
See also | Scheme source file | environment-of-function | |
apply-function | |||
Form | (apply-function function-object actual-parameter-list) | ||
Description | Apply the function object on the given actual parmeters. | ||
See also | Scheme source file | apply-function | |
5 Expressions. | |||
Expressions are encapsluated in functions, which in turn form the basis of methods. The method eval-expr is the main function of a simple, meta circular Scheme interpreter. It has been adapted from the book 'The Scheme Programming Language' by R. Kent Dybvig. | |||
eval-expr | |||
Form | (eval-exr expr env) | ||
Description | Evaluate the expression expr in the environment env. A set of primitive Scheme functions are implicitly found at the rear end of any environment. In case a name is not found in either env, or in the implicit primitive-environment, the name is evaluated in the implementation's interaction environment. | ||
Parameters | expr | The expression to evaluate. An Scheme S-expression. | |
env | The environment, represented as an association list of symbol/value pairs. | ||
See also | Scheme source file | eval-expr | |
6 General ASL2 Standard Objects. | |||
root-object | |||
Form | root-object | ||
Description | The root class in the system. The only class without a superclass. | ||
See also | Scheme source file | root-object | |
Note | In version 2 this ASL2 object was called Object. | ||
class-object | |||
Form | class-object | ||
Description | The implicit superclass of all classes. The superclass of Class is root-object. | ||
See also | Scheme source file | class-object | |
Superclass | root-object | ||
Note | In version 2 this ASL2 object was called Class. | ||
7 Generation of class forms. | |||
The primitive that turns an ASL2 class object into a class description in a source file. | |||
class-source | |||
Form | (class-source class-object class-name superclass-name file-path [role]) | ||
Description | Generate a string with the class source form on a file. If role is provided, generate a mapping for it to the class. | ||
Parameters | class-object | The class object from which to generate the source form | |
class-name | The name of the class (a string) | ||
superclass-name | The name of the superclass (a string), or #f if there is no superclass. Do not attempt to pass Class. | ||
file-path | The path to the file where to write the class source form | ||
role | The role of the objects, which will be mapped to the class (represented by class-object). | ||
See also | Scheme source file | class-source | |