Next: , Previous: , Up: Yasos   [Contents][Index]


3.14.2 Interface

Syntax: define-operation (opname self arg …) default-body

Defines a default behavior for data objects which don’t handle the operation opname. The default behavior (for an empty default-body) is to generate an error.

Syntax: define-predicate opname?

Defines a predicate opname?, usually used for determining the type of an object, such that (opname? object) returns #t if object has an operation opname? and #f otherwise.

Syntax: object ((name self arg …) body)

Returns an object (an instance of the object system) with operations. Invoking (name object arg …) executes the body of the object with self bound to object and with argument(s) arg….

Syntax: object-with-ancestors ((ancestor1 init1)) operation …

A let-like form of object for multiple inheritance. It returns an object inheriting the behaviour of ancestor1 etc. An operation will be invoked in an ancestor if the object itself does not provide such a method. In the case of multiple inherited operations with the same identity, the operation used is the one found in the first ancestor in the ancestor list.

Syntax: operate-as component operation self arg …

Used in an operation definition (of self) to invoke the operation in an ancestor component but maintain the object’s identity. Also known as “send-to-super”.

Procedure: print obj port

A default print operation is provided which is just (format port obj) (see Format) for non-instances and prints obj preceded by ‘#<INSTANCE>’ for instances.

Function: size obj

The default method returns the number of elements in obj if it is a vector, string or list, 2 for a pair, 1 for a character and by default id an error otherwise. Objects such as collections (see Collections) may override the default in an obvious way.


Next: , Previous: , Up: Yasos   [Contents][Index]