[erlang-questions] *current* value?
Thu Oct 18 00:15:48 CEST 2007
I would add a note of caution to your new found understanding. Using
the process dictionary instead of passing parameters in the vast
majority of normal erlang code can lead to the most incredibly
strange bugs, and is almost never what you want.
The use as described in mnesia is a neat hack, and as far as I know
it is the only place it is used in the whole of OTP.
Probably the best place to learn idiomatic erlang is from the sources
to the rest of the (less complex) applications that come with OTP,
and a few of the open source applications out there.
On 17 Oct 2007, at 22:51, YC wrote:
> Great - thanks for the confirmation and explanation.
> On 10/17/07, David King < > wrote:
> Ah, I see. The process dictionary (when used in a read-only fashion,
> as you described earlier) is probably what you're looking for, then.
> That's how mnesia keeps track of your transactions in a construct
> like this:
> mnesia:transaction(fun() ->
> end), ...
> While you don't *specify* anything like current_transaction(),
> mnesia:write() implicitly refers to it, and it sets/gets it in the
> process dictionary. You could write a current_transaction() or
> something that would read it back out of the process dictionary. You
> could also design something like
> Then you're passing your "current transaction" around rather than
> carrying it implicitly. I think that's cleaner. But if you wanted it
> to be implicit, you could use the process dictionary for it like
> mnesia does.
> erlang-questions mailing list
More information about the erlang-questions