[e-lang] Reentrancy via Recursion
Kevin Reid
kpreid at mac.com
Thu Feb 26 10:12:09 EST 2009
On Feb 26, 2009, at 7:18, Toby Murray wrote:
> However, this kind of nondeterminism can already be created in E.
> Suppose we have a variable 'InUse' and Bob is now
>
> def Bob() {
> if (InUse) {
> throw "in use"
> }
> }
>
> Bob is nondeterministic in that Bob() will fail sometimes if called
> in a
> context during which InUse is true.
>
> I see that the first case does reveal information that the second
> doesn't -- about the call-stack. However, I don't see how it adds any
> more nondeterminism than is already present.
Okay, my revised statement:
Checking the call stack *for occurrences of yourself* is safe, and
equivalent to maintaining state. An object which uses this "I call
you, don't call me" operator cannot be considered DeepFrozen.
Furthermore, it can be implemented user-level by a library using an in-
use flag:
def [Bob, protectedCall] := prohibitMarkedReentrance(def Bob0() {
protectedCall(Carol).hello(Bob) # instead of Carol.hello(Bob)
}}
Here Bob is a wrapper around Bob0 which checks the flag which is set
by protectedCall.
--
Kevin Reid <http://homepage.mac.com/kpreid/>
More information about the e-lang
mailing list