[Opa] UserContext and shooting myself in the foot (hangs)

Owen Gunden ogunden at phauna.org
Tue Jan 24 21:41:39 UTC 2012


I keep accidentally shooting myself in the foot with
UserContext.execute. I write something like this:

f(uc) =
  UserContext.execute( (uc_state ->
    // do some stuff..
    some_function(uc)
    // la la la..
  ), uc)

some_function(uc) =
  // do more stuff..
  UserContext.execute( (uc_state -> ...), uc)

And then my program hangs forever when I call f. I think calls to
UserContext.execute from within itself lead to a deadlock. I don't
think I ever actually *need* to do this, I just do it by accident a
lot.

Any pointers on avoiding this situation? I was thinking that since
*most* of the time I only need to read the usercontext, not write it,
I could define a function get_usercontext_state(uc) =
UserContext.execute(x -> x, uc) and use that instead of execute most
of the time. I just wonder if there isn't a sexier type-system way to
make this safer?


More information about the Opa mailing list