PassByConstruction

A PassByConstruction (also 'pbc') object is one which, when sent over a comm system (e.g. CapTP) to another vat, is sent as some serialized representation, and will typically arive near rather than as a far reference back to the originating vat (PassByProxy).

PassByConstruction objects may additionally be Selfless, which by definition makes them PassByCopy, i.e. exactly duplicated. On the other hand, Selfish PassByConstruction objects are used, for example, for una.

Defining pass-by-construction objects
E comm systems serialize any object approved by the  auditor as the portrayal returned by its __optUncall/0 method. For example, this is an object which will always arrive as the number 3:

Example
The first part of the example is a maker for a 2D Vector. The created vectors are Pass By Construction, they should pass the guard :pbc. This code should be positioned in an emaker file in the java classpath at the location "tests/makeVector.emaker"

def makeVector implements pbc { to run(var x, var y) { def vector implements pbc { to getX :any { return x } to getY :any { return y } to __optUncall :any { return [makeVector, "run", [x,y]] } to __printOn(out) {out.print(`&lt;Vector $x $y&gt;`)} }       return vector }   to __optUncall :any { return [&lt;import&gt;, "get", ["tests.makeVector"]] } }

Example of usage:

? def makeVector := &lt;import:tests.makeVector&gt;
 * 1) create a new Vector object
 * 1) value: &lt;makeVector&gt;

? def vector := makeVector(6.6,7.7)
 * 1) value: &lt;Vector 6.6 7.7&gt;

? introducer.onTheAir
 * 1) value: ["3DES_SDH_M2", "3DES_SDH_M"]

? def seedVatAuthor := &lt;elang:interp.seedVatAuthor&gt;(&lt;unsafe&gt;).virtualize(introducer)
 * 1) function for creating a new local vat
 * 1) value: &lt;virtualSeedVat&gt;

? def scriptSource:="def run(thing :pbc) {println(`Thing: $thing`)}"
 * 1) Run this source code in the new vat. The method accepts a pbc object and prints it.
 * 1) value: "def run(thing :near) {println(`Thing: $thing`)}"

? def [scriptObj, vat] := seedVatAuthor(scriptSource)
 * 1) create the new vat. Return a far reference to the object and a reference to the vat object
 * 1) value: [&lt;Promise&gt;, &lt;Vat newVirtualSeedVat in &lt;runs in newVirtualSeedVat&gt;&gt;]

? scriptObj &lt;- run(vector)
 * 1) pass the pbc object into the new vat
 * 1) value: &lt;Remote Promise&gt;

? Thing: &lt;Vector 6.6 7.7&gt;