Singular/Sources — pull request #180 by alexanderdreyer (2012-09-06 18:59:03+00:00)
Title: Extension: blackbox types 'reference' and 'shared'

In this pull request, you'll find a bunch of patches, introducing new blackbox-based data types `reference` and `shared`. `reference` uses a reference counted wrapper to adds multiple handles for a given identifier, each of which can be copied, stored and handed over without actually copying the represented Singular data. `shared` uses a similar approach, but is not tied to an existing identifier.
```C
> int i = 0;
> reference ref = i;
> shared sh = 12;
> ref + sh; // automated 'dereferencing'
12
> ref + 4;
4
> list ll = list(ref, ref, ref, ref, ref, ref, ref);
> string(ll);
0,0,0,0,0,0,0
> ref = 1;
> string(ll); // all one now
1,1,1,1,1,1,1
> list changeme; // proc may have side-effects now!
> changeme;
empty list
> proc setfirst(reference ll, def arg) { ll[1] = arg; }
> setfirst(changeme, 17);
> changeme[1];
17
```

The patches also contains an extensive test file `countedref_s.tst` and the documentation chapter `countedref.doc`. The "spielwiese" variant is under preparation, but spielwiese lacks some blackbox features to be merged.