[newbie] spawn-ed functions always exported?

Carsten Schultz carsten@REDACTED
Wed Jan 26 16:05:16 CET 2005


Hi!

On Wed, Jan 26, 2005 at 06:36:10PM +0400, Gaspar Chilingarov wrote:
> Hello all!
> 
> Are there any way not to export functions which are logically internal 
> to the module, but appear in spawn command ?

This seems simple enough for me to answer, so I will try :-)

Instead of

    spawn(?MODULE, f, [A1, A2, A3])

you can use

    spawn(fun ()->f(A1, A2, A3) end)

Note however that these two will have slightly differing behaviour in
the presence of hot code update.  Afaik the first one will spawn the
function of the newest version of the module, while the second one
will spawn the function of the version of the module executing the
spawn function.

Greetings,

Carsten

-- 
Carsten Schultz (2:38, 33:47)
http://carsten.codimi.de/
PGP/GPG key on the pgp.net key servers, 
fingerprint on my home page.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20050126/1ca32a92/attachment.bin>


More information about the erlang-questions mailing list