[erlang-questions] How to dynamically compiled module?

Solomon solomon.wzs@REDACTED
Wed Jan 9 11:16:30 CET 2013


It is ok when I call the function like that: mochiglobal:put(key, [1, 2,
3]).

But it is error when I call the function like that: mochiglobal:put(key,
self()).

I know I could save the variable like that: mochiglobal:put(key,
term_to_binary(self())), but I want to know whether there are some methods
to save pid or port directly.

Thanks.


2013/1/9 Andrew Majorov <encube.ul@REDACTED>

> I beleive mochiglobal is exactly what you are searching for. Note this is
> more or less legacy stuff. If you are just into the deal with global
> variables, IMO ets or dedicated process is more appropriate.
>
> https://github.com/mochi/mochiweb/blob/master/src/mochiglobal.erl
>
> I want to save a variable and number of threads would call it, but I don't
>> want to save it in ets.
>>
>> I want to dynamically compiled a module, when I call foo:bar(), it will
>> return the variable directly.
>>
>> How should I do?
>>
>> (P.S. the variable like this: {#Fun<...>, <0.1.0>, ...})
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20130109/57fa2711/attachment.htm>


More information about the erlang-questions mailing list