[newbie] spawn-ed functions always exported?
Rick Pettit
rpettit@REDACTED
Wed Jan 26 16:20:08 CET 2005
On Wed, Jan 26, 2005 at 03:57:50PM +0100, Joe Armstrong (AL/EAB) wrote:
>
> 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]).
You shouldn't need the b/2 in export list with the new way.
-Rick
> a() -> spawn(fun() -> b(1,2) end).
>
> b(X, Y) ->
> ...
>
> Cheers
>
> /Joe
>
> (also for spawn_link)
More information about the erlang-questions
mailing list