class-instances-countGBBopen Coredelete-instancedefine-unit-classGoTo Top

define-unit-class   unit-class-name ({superclass-name}*) ({slot-specifier}*) {class-option}* => new-unit-class[Macro]

Define or redefine a unit class.

Package   :gbbopen

Module   :gbbopen-core

Arguments and values

unit-class-name     A non-nil, non-keyword symbol that names the unit class
superclass-name     A non-nil, non-keyword symbol that specifies a direct superclass of the unit class unit-class-name
slot-specifiers     See below
class-options     See below
new-unit-class     A new or modified unit class object

The newly defined or modified unit class object.

The specified superclass-names do not include at least one unit class name. This error is signaled on class finalization.

Detailed syntax
[Syntax shown in gray is not supported in GBBopen Version 1.5, but will become available in a future release.]

slot-specifier ::= slot-name |
(nonlink-slot-name [[nonlink-slot-option]]) |
(link-slot-name [[link-slot-option]])

nonlink-slot-name ::= slot-name
link-slot-name ::= slot-name
link-slot-option ::= slot-option |
{:link inverse-link-slot-specifier} |
{:singular boolean} |
{:sort-function function} |
{:sort-key function}
inverse-link-slot-specifier ::= (unit-class-name link-slot-name [:singular boolean]) |
nonlink-slot-option ::= slot-option |
{:reader reader-function-name}* |
{:writer writer-function-name}*
slot-option ::= {:accessor reader-function-name}* |
{:allocation allocation-type} |
{:documentation string} |
{:initarg initarg-name}* |
{:initform form} |
{:type type-specifier}
class-option ::= (:abstract boolean) |
(:default-initargs . initarg-list) |
(:dimensional-values dimension-value-specifier*) |
(:documentation string) |
(:estimated-instances size-form) |
(:export-accessors boolean) |
(:export-class-name boolean) |
(:export-slot-names direct-slots-specifier) |
(:generate-accessors direct-slots-specifier) |
(:generate-accessors-format {:prefix | :suffix} |
(:generate-accessors-prefix {string | symbol}) |
(:generate-accessors-suffix {string | symbol}) |
(:generate-initargs direct-slots-specifier) |
(:initial-space-instances initial-space-instance-specifier) |
(:instance-name-comparison-test instance-name-comparison-test) |
(:metaclass class-name) |
(:retain {boolean | :propagate}) |
(:use-global-instance-name-counter boolean)
initial-space-instance-specifier ::= {space-instance-path+ | function}
dimension-value-specifier ::= incomposite-dv-specifier | composite-dv-specifier
incomposite-dv-specifier ::= (dimension-name dimension-value-spec dimension-value-place)
composite-dv-specifier ::= (dimension-name dimension-value-specifier
  composite-type dimension-value-place)
composite-type ::= :set | :sequence |
{:ascending-series ordering-dimension-name} |
{:descending-series ordering-dimension-name}
dimension-value-specifier ::= dimension-value-type |
(ordered-dimension-value-type [ordered-comparison-type]) |
(enumerated-dimension-value-type [enumerated-comparison-type]) |
(boolean-dimension-value-type [boolean-comparison-type])
dimension-value-type ::= ordered-dimension-value-type |
enumerated-dimension-value-type |
ordered-dimension-value-type ::= :point | :interval | :mixed
enumerated-dimension-value-type ::= :element
boolean-dimension-value-type ::= :boolean
ordered-comparison-type ::= number | fixnum | short-float | single-float |
double-float | long-float |
enumerated-comparison-type ::= eq | eql | equal | equalp
boolean-comparison-type ::= t
dimension-value-place ::= {slot-name [slot-name]} | {function [slot-name]}
direct-slots-specifier ::= nil | t | included-slot-name* |
{t :exclude excluded-slot-name*}

The default ordered-comparison-type, if unspecified, is number. The default enumerated-comparison-type, if unspecified, is eql. The default boolean-comparison-type is t.

A dimension-value-place with two slot-names is allowed only for an :interval dimension-value specification.


class-name     A non-nil, non-keyword symbol that names a class
dimension-name     A symbol specifying a dimension
documentation     A documentation string
initarg-list     An initialization argument list
instance-name-comparison-test     One of the four standardized hash table test function names: eq, eql, equal, or equalp (default for classes of metaclass standard-unit-class is eql)
ordering-dimension-name     A symbol specifying the ordering dimension used to order series-composite dimension values
size-form     An integer or an expression that evaluates to an integer (evaluation occurs whenever the unit class is initialized, reinitialized, or reset)
slot-name     A non-nil, non-keyword symbol

A dimension-value-place with two slot-names can be specified only for :interval dimension-value types.

If dimension-value-place is specified as a function without a qualifying slot-name, function is called with the unit instance rather than a slot value. In this case, function is responsible for handling any unbound slots that it references, returning unbound-value-indicator when appropriate.

Each superclass-name argument specifies a direct superclass of the new class. If the superclass list is empty, then the direct superclass defaults to the single class standard-unit-instance.

The :metaclass class option, if specified, must be a subclass of standard-unit-class. The default metaclass value is standard-unit-class.

Inheritance of class options

The set of dimensional-values for a unit class is the union of the sets specified in the dimensional-values options of the class and its superclasses. When more than one dimension-value specification is supplied for a given dimension, the one supplied by the most specific class is used.

The effective initial-space-instances value for a unit class is the value specified in the definition of the most specific unit class. (No additive inheritance of initial-space-instances is performed.) If no definitions specify an initial-space-instances value, nil is used.

The instance-name-comparison-test value is not inherited. If no value is specified in the unit-class definition, the default initialization value associated with the metaclass is used.

If a retain value is not specified, a value of :propagate is used as the default if any parent unit classes have a :propagate retention value; otherwise nil is used as the default value.

The use-global-instance-name-counter value is not inherited. If no value is specified in the unit-class definition, the default initialization value associated with the metaclass is used.

See also

Define a unit class, hyp, that illustrates a number of define-unit-class capabilities:

  > (define-unit-class hyp ()
      ((belief :initform 0.0)
       (location :initform nil)
       (classification :initform '(:car :truck :bus :motorcycle :train :duck-boat 
                                   :lawn-mower :anything))
        :link (hyp supported-hyps))
        :link (hyp supporting-hyps)))
       (belief :point belief)
       (velocity-range :interval velocity-range)
       (color (:element eq) color)
       (classification (:element eq) :set classification)
       (x (:point fixnum) #'location.x location)
       (y (:point fixnum) #'location.y location))
      (:initial-space-instances (bb hyps)))
  #<standard-unit-class hyp>

Define a unit class, word, whose instances are indexed by the word's individual characters in an enumerated dimension and the code-char values of the individual characters in an ordered dimension:

  > (define-unit-class word ()
      ((string :initform "what's"))
       (character :element :set string)
       (char-code (:point fixnum) :set 
                  #'(lambda (string)
                      (map 'list #'char-code string))
      (:initial-space-instances (words)))
  #<standard-unit-class word>

The GBBopen Project

class-instances-countGBBopen Coredelete-instancedefine-unit-classGoTo Top