# Copyright 2007 Kevin Reid, under the terms of the MIT X license # found at http://www.opensource.org/licenses/mit-license.html ................ This is a copy of the pass-by-construction.updoc I wrote for E-on-Java, with the multivat parts commented out until E-on-CL supports them. It currently only tests the PBC auditor and related things. ? pragma.syntax("0.9") x ? def seedVat := () x ? def vsv := seedVat.virtualize((introducer.onTheAir(); introducer)) x # value: x x ? def [otherEval, vat] := x > vsv("fn src { e__quasiParser(src).eval(safeScope) }") x # value: [, \ x # >] x x ? def other := otherEval <- ("fn x { x }") ? def obj implements pbc { to __optUncall() :any { > return [, "make", []] > }} # value: ? Ref.isPBC(obj) # value: true ? Ref.isPassByCopy(obj) # value: false ? obj :pbc # value: x ? def r := interp.waitAtTop(other <- (obj)) x ? r x # value: x x ? r <- push(1) x # value: x x ? r <- push(2) x # value: x x ? def s := interp.waitAtTop(r <- snapshot()) x ? s x # value: [1, 2] Odd case: maker is near only on receipt x ? def otherMaker := interp.waitAtTop( x > otherEval <- ("fn { def oddFar {} }")) x ? otherMaker x # value: x x ? def r := interp.waitAtTop( x > other <- ( x > def oddNear implements pbc { x > to __optUncall() { x > return [otherMaker, "run", []] } })) x ? r x # value: x x ? def otherCall := otherEval <- ("fn r,v,a { E.call(r,v,a) }") x # value: x x ? def t := interp.waitAtTop(otherCall <- (E, "toString", [r])); null x ? t x # value: "" Auditing details ? Ref.isPBC(def notHonestlyPBC implements pbc {}) # value: true Miscellaneous ? def pbcs := [ > #0, > #' ', > #false, > "" :(), > # makeSturdyRef.temp(1), > # , > # :(), > #(null), > [].asMap(), > [].asSet(), > [], > ] > for i => thing in pbcs { > if (!Ref.isPBC(thing)) { > println(`#$i should be PBC: `, > thing, > " ", > thing.__getAllegedType().getFQName()) > } > } > print("of ", pbcs.size()) # stdout: of 4 ? def notpbcs := [ > def _ {}, > def _ {} :(), > , > ] > for i => thing in notpbcs { > if (Ref.isPBC(thing)) { > println(`#$i shouldn't be PBC: `, > thing, > " ", > thing.__getAllegedType().getFQName()) > } > } > print("of ", notpbcs.size()) # stdout: of 3