create [Function]

createm [Macro]


Purpose

The create function creates a new Loom or CLOS instance of a specified type.

The createm macro creates a new instance, and then calls the Loom instance classifier to compute the type of the instance (and of any other instances currently on the classify queues).

Syntax

create identifier concept &key kb add-suffix-p clos-instance-p
createm identifier concept &key kb add-suffix-p clos-instance-p

Arguments

The identifier argument is a symbol or string which identifies the new instance. If the instance is a Loom instance, or inherits the mixin INSTANCE-IN-KNOWLEDGE-BASE, and its identifier is nil, it is given a unique system-generated identifier.

The concept argument is the concept, or the name of the concept, to be used as the creation type of the new instance. When no concept is supplied, the creation type is Thing.

The kb argument is the knowledge base in which the new instance will be interned. This defaults to the current knowledge base.

If the add-suffix-p argument is t, identifier is suffixed with a unique integer. If identifier is nil, this is a no-op.

If the clos-instance-p argument is t, or if the global feature :prefer-clos-instances is set, a CLOS instance (see make-object) is created instead of a Loom instance. If there is no existing CLOS class corresponding to concept, Loom attempts to create the needed class. If this attempt fails, or if concept is nil, a standard Loom instance is created, and a warning is issued unless the value of clos-instance-p is :no-warning.

Value

These functions return the newly-created instance.

Remarks

The new instance does not actually assume its creation type until a createm, or some other function such as tellm or new-time-point, causes the instance classifier to be run.

If identifier is the same as the identifier of an existing instance, Loom asks whether the user wants to clobber the old instance (and possibly compromise the integrity of the database) or ignore the request for a new instance.

The creation type of an instance can never be retracted.

Examples

      (createm 'Joe 'A) ==> |I|JOE
      (create 'Fred nil) ==> |I|FRED
      (createm nil (fc A) :kb (find-kb "USER-KB")) ==> |I|A-13
      (create 'Sue 'A :clos-instance-p t) ==> |i|SUE
      (create nil 'A :clos-instance-p t) ==> #<A #X20FDDFE>
      (createm 'Fred nil :add-suffix-p t) ==> |I|FRED-14
      (create nil nil :clos-instance-p t) ==> |I|THING-15

See Also

Last modified: Sep 20 1995