Virtual sealer/unsealer Pairs (was: Comments on FC00 paper) Mark S. Miller (markm@caplet.com)
Tue, 02 Nov 1999 16:11:16 -0800

At 02:27 PM 11/2/99 , Marc Stiegler wrote: >I have this suspicion this is a trick question.

Here's a trick answer. The prefix "i" means internal, and "v:" means virtual. This is a trivial implementation of sealer/unsealer pairs in E built on the primitive ("i") sealer/unsealer pairs provided by the E kernel. This is in the spirit of simple interpreters for languages written in themselves. It is actually important, because it shows that variants of the primitive sealer/unsealer pairs can easily be built in the language. The primitive doesn't have to directly accommodate all uses, as long as it is adequate for building abstractions that can. The following user-defined version is polymorphic with the original.

? define BrandMaker := import:org.erights.e.elang.sealing.Brand # value: <statics of org.erights.e.elang.sealing.Brand>

? define VirtualBrandMaker pair(name) : any {
> define [iSealer, iUnsealer] := BrandMaker pair(name)
> define envelopeMaker(contents) : any {
> define envelope {
> to printOn(out) { out print(`<v: sealed by $name>`) }
> to iGetContents : any { iSealer seal(contents) }
> }
> }
> define sealer {
> to printOn(out) { out print(`<v: $name sealer>`) }
> to seal(contents) : any { envelopeMaker(contents) }
> }
> define unsealer {
> to printOn(out) { out print(`<v: $name unsealer>`) }
> to unseal(envelope) : any { iUnsealer unseal(envelope
iGetContents) }
> }
> [sealer, unsealer]

> }
# value: <VirtualBrandMaker>

? define [sealer, unsealer] := VirtualBrandMaker pair("Chip") # value: [<v: Chip sealer>, <v: Chip unsealer>]

? define env := sealer seal("foo")
# value: <v: sealed by Chip>

? unsealer unseal(env)
# value: foo

         Cheers,
         --MarkM