[e-lang] The Donnelley Dynamic Revocation Pattern
Mark Miller
erights at gmail.com
Sun Aug 12 23:29:52 EDT 2007
Jed suggested the following pattern during a discussion between Jed,
Adrian Mettler, and I at Usenix.
---------------------------
def makeMembrane := <import:org.erights.e.facet.makeMembrane>
/**
* The Donnelley Dynamic Revocation Pattern.
* <p>
* Given a target object, dynamic(target) returns a reference
* providing temporally deeply-attenuated authority to target. Any
* non-Miranda invocation of this reference forwards this invocation to
* a newly constructed membrane around target. Once this invocation
* exits, whether normally or abruptly, the membrane is revoked.
*
* @author Jed Donnelley
* @author Mark S. Miller
*/
def dynamic(target) {
def dynamicWrapper {
match [verb, args] {
def [t, gate] := makeMembrane(target)
try {
E.call(t, verb, args)
} finally {
gate.disable()
}
}
}
return dynamicWrapper
}
? pragma.syntax("0.9")
? def dynamic := <import:org.erights.e.facet.dynamic>
# value: <dynamic>
? var loot := null
? def stealer {
> /** Note: not the Miranda __printOn */
> to printOn(out) {
> loot := out
> out.print("<stealer>")
> }
> }
# <stealer>
? stealer.printOn(stdout)
# stdout: <stealer>
? loot
# value: <a TextWriter>
? loot := null
? dynamic(stealer).printOn(stdout)
# stdout: <stealer>
? loot
# value: <caretaker>
? loot.print("foo")
# problem: disabled
--
Text by me above is hereby placed in the public domain
Cheers,
--MarkM
More information about the e-lang
mailing list