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

Owen Gunden ogunden at phauna.org
Wed Jan 25 01:53:41 UTC 2012


I just noticed that opaDo keeps the usercontext inside the User module
as global state. I think adopting that model will largely solve my
issues as they are related to threading the usercontext through all my
function calls.

I'm still interested if anyone has thoughts on a way to make this
mistake more difficult to do by accident.

On Tue, Jan 24, 2012 at 4:41 PM, Owen Gunden <ogunden at phauna.org> wrote:
> 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