Home Online Manual
Top
Back: shared declarations
Forward: reference and shared operations
FastBack: pyobject
FastForward:
Up: countedref
Top: Singular Manual
Contents: Table of Contents
Index: Index
About: About this document

4.28.4 shared expressions

shared expression:

  1. any expression
  2. an object of type shared (result will reference the same data)


Example:

 
system("reference"); system("shared");
  shared sh = 17;  // new shared
  shared second = sh;
  second;
==> 17
==> 
  second = 9;       // also tied to 'sh'
  sh;
==> 9
==> 
  typeof(sh);
==> shared

  shared ll = list(1, 2, 3);
  shared lref = ll[1];
  lref;
==> 1
==> 
  lref = 12;
  ll;
==> [1]:
==>    12
==> [2]:
==>    2
==> [3]:
==>    3
==>