Defining Forms

define-class

Sets the variable NAME to a new class: a new instance of the class <class> or METACLASS, if supplied.

SUPERCLASS ... is a list of superclasses of the newly created class. If no superclasses are given, then <object> is assumed.

SLOT-NAME ... are the names of the direct slots of the class. A SLOT-NAME is a symbol.

By convention, identifiers bound to classes in TinyCLOS are denoted by angle brackets as above. This is not required, however. A class may be bound to any identifier without affecting the behavior of the system.

define-method

Adds a new method with the code BODY ... to the generic function bound to NAME.

CLASS1 ... is a list if classes that specialize this particular method.

The method can have additional ARGUMENTS, which do not specialize the method any further. Extended lambda-lists are allowed (argument lists with #!optional, #!key, and/or #!rest), but cannot be specialized.

Inside the BODY ... of the method the identifier call-next-method names a procedure of zero arguments that can be invoked to call the next applicable method with the same arguments.

compute-getter-and-setter

Returns two values, the procedures that get and set the contents of the slot SLOT. ALLOCATOR is a procedure of one argument that gets an initializer function and returns the getter and setter procedures for the allocated slot.

compute-method-more-specific?

Returns a procedure of three arguments (two methods and a list of arguments) that returns #t if the first method is more specific than the second one with respect to the list of arguments. Otherwise the returned predicate returns #f.

compute-slots

<generic>(compute-slots CLASS) => list</generic>

Computes and returns the list of slots of CLASS.

initialize

<generic>(initialize INSTANCE INITARGS)</generic>

Initializes the object INSTANCE. INITARGS is the list of initialization arguments that were passed to the make procedure.

Note the slot name can only be initialized with a string or symbol, which is coerced to a string. When the supplied name follows the canonical form for class names, <...>, the outer angle brackets are stripped.

Additional Protocol

print-object

<generic>(print-object INSTANCE [PORT])</generic>

Writes a terse textual representation of INSTANCE to PORT. Any output of an instance with display, write, and print will invoke this generic function.

If PORT is not given it defaults to the value of (current-output-port).

describe-object

<generic>(describe-object OBJECT [PORT])</generic>

Writes a verbose textual description of OBJECT to PORT.

If PORT is not given it defaults to the value of (current-output-port).

If given an instance, this procedure will identify the class to which the instance belongs and list the names and values of all its slots. If given a primitive, this procedure will identify the primitive class to which the argument belongs.

License

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

Redistributions of source code must retain the above copyright notice, this list of conditions and the following
disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided with the distribution.
Neither the name of the author nor the names of its contributors may be used to endorse or promote
products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.