[erlang-questions] *current* value?

YC yinso.chen@REDACTED
Wed Oct 17 21:34:47 CEST 2007


Hi Vance -

Thanks for the explanations for the different approaches in Erlang - this is
great.

Hopefully this follow-up doesn't make me sound like a troll - but I can't
help but notice that ets and even Mnesia is recommended before process
dictionary (which is very heavily frowned upon) in this thread, and I am not
sure if I understand the reason, unless process dictionary is technically
inferior or broken.  From FP perspective, neither is pure, so why one better
than another?

There must be a reason for the level of discouragement about a built-in
facility.

If this is a trite question - I apologize in advance.

Thanks,
yc

On 10/17/07, Vance Shipley < vances@REDACTED> wrote:
>
> YC,
>
> As I see it the process dictionary has one and only one
> legitimate purpose and that is to store process data for
> OTP tools such as the debugger.  If you are building a
> library to add tool functions to arbritray code modules
> than using the process dictionary may be reasonable.
>
> If you need a variable to persist through function calls
> you would normally pass it as a function argument.  If
> there are too many consider storing variable data in records
> and pass the record (i.e. #state{a=1, b=2, ...}).
>
> If there is too much process data for that approach look
> to using ets.  Beyond that look to mnesia.
>
> For a purely functional solution use a seperate process to
> store the data and use message passing.
>
>         -Vance
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20071017/fb201aaf/attachment.htm>


More information about the erlang-questions mailing list