|  |  4.28.6 reference and shared related functions 
 
defexplicitly type casts to referenceorshared, respectively.
(Note: For thedefdeclaration, see  def.)
Example:
 |  | system("reference"); system("shared");
int i =1;
reference ref = i;
shared sh = 17;
list ll = list(ref, ref, ref, sh, sh);
ll[1] = 2;      // replace only one entry
ll;
==> [1]:
==>    2
==> [2]:
==>    1
==> 
==> [3]:
==>    1
==> 
==> [4]:
==>    17
==> 
==> [5]:
==>    17
==> 
def(ll[2]) = 3;      // change the others
ll;
==> [1]:
==>    2
==> [2]:
==>    3
==> 
==> [3]:
==>    3
==> 
==> [4]:
==>    17
==> 
==> [5]:
==>    17
==> 
def(ll[4]) = 19;     // same here
ll;
==> [1]:
==>    2
==> [2]:
==>    3
==> 
==> [3]:
==>    3
==> 
==> [4]:
==>    19
==> 
==> [5]:
==>    19
==> 
 | 
 
linkexplicitly dereference a referenceorsharedobject.
(Note: For thelinkdeclaration, see  link.)
Example:
 |  | system("reference"); system("shared");
ring r = 0, (x,y,z), dp;
poly p = x + y + z;
def x_=x;
reference xref=x_;
xref;
==> x
==> 
subst(p, xref,1, y,2, z,3);        // fails
==>    ? subst(`poly`,`reference`,`int`) failed
==>    ? expected subst(`poly`,`poly`,`poly`)
==>    ? expected subst(`matrix`,`poly`,`int`)
==>    ? error occurred in or before ./examples/reference_and_shared_related_\
   functions_1.sing line 7: `subst(p, xref,1, y,2, z,3);        // fails`
subst(p, link(xref),1, y,2, z,3);  // fine
==> 6
 | 
 
systemThe referenceandsharedobjects overload thesystemcommand to gain extended features, seesystem(ref, "help")for more details.
(Note: For the generalsystemcommand, see  system.)
Example:
 |  | system("reference"); system("shared");
shared sh;
system(sh, "help");
==> system(<ref>, ...): extended functionality for reference/shared data <ref\
   >
==>   system(<ref>, count)         - number of references pointing to <ref>
==>   system(<ref>, enumerate)     - unique number for identifying <ref>
==>   system(<ref>, undefined)     - checks whether <ref> had been assigned
==>   system(<ref>, "help")        - prints this information message
==>   system(<ref>, "typeof")      - actual type referenced by <ref>
==>   system(<ref1>, same, <ref2>) - tests for identic reference objects
 | 
 
 |