make-duplicate-instanceGBBopen Coremake-instancemake-duplicate-instance-changing-classGoTo Top

make-duplicate-instance-changing-class   instance new-class unduplicated-slot-names &rest initargs &key &allow-other-keys => new-instance, slots[Generic Function]

Purpose
Create a duplicate instance of instance, changing its class to new-class in the process.

Method signatures

make-duplicate-instance-changing-class  (instance standard-object) (new-class class) unduplicated-slot-names &rest initargs => new-instance, slots
make-duplicate-instance-changing-class  (instance standard-object) (new-class standard-space-class) unduplicated-slot-names &rest initargs => new-space-instance, slots
make-duplicate-instance-changing-class  (instance standard-object) (new-class standard-unit-class) unduplicated-slot-names &rest initargs => new-unit-instance, slots
make-duplicate-instance-changing-class  (instance standard-object) (new-class symbol) unduplicated-slot-names &rest initargs => new-instance, slots
make-duplicate-instance-changing-class  :around (instance standard-unit-instance) (new-class standard-unit-class) unduplicated-slot-names &rest initargs => new-unit-instance, slots

Package   :gbbopen-tools (re-exported by :gbbopen)

Module   :gbbopen-tools (the unit-instance and space-instance methods are added by :gbbopen-core)

Arguments and values

instance     A standard-object instance
new-class     A class designator
unduplicated-slot-names     A list of slot names
initargs     An initialization argument list
new-instance     A standard-object instance
slots     A proper list of slot objects

Returns
Two values: the (newly created) duplicate instance and a list of the slots that were duplicated or explicitly initialized.

Events
When a unit instance is duplicated, events are signaled in the following sequence:

  1. An nonlink-slot-updated-event or link-event is signaled for each initialized slot in the duplicated unit instance. A link-event is also signaled for each inverse pointer from an existing unit instance to the (newly created) duplicate unit instance.
  2. An instance-added-to-space-instance-event is signaled for each space instance on which the duplicate unit instance is added.
  3. A instance-created-event is signaled.

Errors
Use of an initialization argument that has not been declared as valid.

Description
Slot initialization during instance duplication behaves as follows, regardless of whether the slots are local or shared:

When creating (duplicating) a new unit instance, specifying a :instance-name initialization argument causes that value to be used as the instance name of the newly created unit instance instead of the instance-name counter value associated with the unit class (if the :use-global-instance-name-counter class option is nil or was not specified for the unit class) or the global instance-name counter value (if the :use-global-instance-name-counter class option is true for the unit class).

A :space-instances initialization argument must be provided when creating a new a space instance.

See also
    change-class
    delete-instance
    describe-instance
    initial-class-instance-number
    instance-name-of
    make-duplicate-instance
    make-instance
    make-space-instance
    next-class-instance-number
    unduplicated-slot-names

Examples
Create some simple duplicate instances:

  > (define-class foo () 
       ((a :initform 1)
        (b :initform 2)))
  #<standard-class foo>
  > (define-unit-class bar () 
       ((a :initform 1)
        (b :initform 2)))
  #<standard-class bar>
  > (defparameter *x* (make-instance 'foo :a 11 :b 12))
  *x*
  > :ds *x*
  #<foo #x110fe6ea> is an instance of #<standard-class foo>:
   The following slots have :instance allocation:
    a   11
    b   12
  > :ds (make-duplicate-instance-changing-class *x* 'foo nil :a -1)
  #<foo #x110ff93a> is an instance of #<standard-class foo>:
   The following slots have :instance allocation:
    a   -1
    b   12
  > :ds (make-duplicate-instance-changing-class *x* 'bar nil :b 2)
  #<bar #x11100032> is an instance of #<standard-unit-class bar>:
   The following slots have :instance allocation:
    a   11
    b   2
  > :ds (make-duplicate-instance-changing-class *x* 'bar '(b) :a -1)
  #<bar #x11104542> is an instance of #<standard-unit-class bar>:
   The following slots have :instance allocation:
    a   -1
    b   2
  > :ds (make-duplicate-instance-changing-class *x* 'bar '(b))
  #<bar #x11108c82> is an instance of #<standard-unit-class foo>:
   The following slots have :instance allocation:
    a   11
    b   2
  > (make-duplicate-instance-changing-class *x* 'bar nil)
  #<bar @ #x1110a0e2>
  (#<standard-effective-slot-definition b>
   #<standard-effective-slot-definition a>)
  >

Create a duplicate of the hyp 419 unit instance as a probable-hyp:'

  > (make-duplicate-instance-changing-class 
      (find-instance-by-name 19 'hyp)
      'possible-hyp nil)
  #<possible-hyp 681 (1835 4791) 0.85 [5..35]>
  >


The GBBopen Project


make-duplicate-instanceGBBopen Coremake-instancemake-duplicate-instance-changing-classGoTo Top