[newbie] spawn-ed functions always exported?

Joe Armstrong (AL/EAB) joe.armstrong@REDACTED
Wed Jan 26 15:57:50 CET 2005


    Yes.

    Replace 
		spawn(Mod, Func, [Arg1,Arg2,...,Argn]) 

    with
		spawn(fun() -> Mod:Func(Arg1,Arg2,...,Argn) end)


   Example:

Old way

    -module(foo).

    -export([a/0, b/2]).

    a() -> spawn(?MODULE, b, [1,2]).

    b(X, Y) -> 
	...

new way

    -module(foo).
    -export([a/0, b/2]).

    a() -> spawn(fun() -> b(1,2) end).

    b(X, Y) -> 
	...

Cheers

/Joe

(also for spawn_link)

       

> -----Original Message-----
> From: owner-erlang-questions@REDACTED 
> [mailto:owner-erlang-questions@REDACTED]On Behalf Of Gaspar 
> Chilingarov
> Sent: den 26 januari 2005 15:36
> To: erlang-questions@REDACTED
> Subject: [newbie] spawn-ed functions always exported?
> 
> 
> Hello all!
> 
> Are there any way not to export functions which are logically 
> internal 
> to the module, but appear in spawn command ?
> 
> 
> or there are some misdesing issue, and usually in good 
> designed system 
> they are public by design, but not the language limitation?
> 
> 
> thanks in advance
> 
> 
> -- 
> Gaspar Chilingarov
> System Administrator
> 
> t +3749 419763
> w www.web.am
> e nm@REDACTED
> 



More information about the erlang-questions mailing list