[erlang-questions] what is the correct syntax to spawm a MFA with no arguments?

Hynek Vychodil <>
Thu May 1 19:13:38 CEST 2008


Really? Are you sure? Well, then describe us how long live running server
turning around one loop/x function can change code of loop when you don't
export loop/x function or some other function called from its loop. Just
explain.

On Thu, May 1, 2008 at 6:39 PM, Richard Carlsson <> wrote:

> Jarrod Roberson wrote:
> > so are you saying you can do hot code reloading _without_ using the MFA
> > version of spawn?
>
> Yes. If you spawn a process whose starting point is in the same module,
> you just use spawn(fun loop/0) or spawn(fun () -> loop(...) end). If you
> spawn a process that starts in _another_ module, you can write
> spawn(fun moo:loop()) or spawn(fun () -> moo:loop(...) end). Of course,
> in the latter case the function must be exported from moo, but you never
> need to export a function in the current module just because you want it
> to be the starting point of a process.
>
> I know that Joe's book (sadly) contains a remark that indicates that
> there is some problem with dynamic code loading and spawning from a fun,
> but that remark is just misleading.
>
> If you avoid exporting functions that shouldn't really be exported,
> tools like dialyzer can make a much better job of finding out what
> your program is doing (and tell you where you screw up).
>
>     /Richard
> _______________________________________________
> erlang-questions mailing list
> 
> http://www.erlang.org/mailman/listinfo/erlang-questions
>



-- 
--Hynek (Pichi) Vychodil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080501/197a98b8/attachment.html>


More information about the erlang-questions mailing list