Clone

Clone(a) creates a copy of the object a.

The statement $a=b$ for objects creates two variables pointing to the same object. Changing the value of one object changes the value of the other.

Input

  • a : object of any type

Output

  • a' : object of same type as a and an exact copy of it.

Example a=b

A small example showing the effect on b after changing a when a=b:

Input

CloneNot.Quanty
-- some example codedofile("../definitions.Quanty")
 
Opp2 = Opp1 
Opp1.Name = "I'm the name of operator one"
Opp2.Name = "I'm the name of operator two"
print(Opp1.Name)
print(Opp2.Name)
 
psi2 = psi1
psi1.Name = "I'm the name of psi one"
psi2.Name = "I'm the name of psi two"
print(psi1.Name)
print(psi2.Name)

Result

CloneNot.out
I'm the name of operator two
I'm the name of operator two
I'm the name of psi two
I'm the name of psi two

Example a=Clone(b)

A small example showing a=Clone(b):

Input

Clone.Quanty
dofile("../definitions.Quanty")
 
Opp2 = Clone(Opp1) 
Opp1.Name = "I'm the name of operator one"
Opp2.Name = "I'm the name of operator two"
print(Opp1.Name)
print(Opp2.Name)
 
psi2 = Clone(psi1)
psi1.Name = "I'm the name of psi one"
psi2.Name = "I'm the name of psi two"
print(psi1.Name)
print(psi2.Name)

Result

Clone.out
I'm the name of operator one
I'm the name of operator two
I'm the name of psi one
I'm the name of psi two

Example a=a+b

A small example showing that operations acting on objects lead to cloning the object:

Input

CloneAuto.Quanty
dofile("../definitions.Quanty")
 
Opp = Opp1 + Opp2
Opp.Name = "I'm the name of operator Opp and different from Opp1 and Opp2"
print(Opp1.Name)
print(Opp2.Name)
print(Opp.Name)

Result

CloneAuto.out
Lx
Ly
I'm the name of operator Opp and different from Opp1 and Opp2

Table of contents

Print/export