[erlang-questions] What is the function be defined as BIF?
Bengt Kleberg
bengt.kleberg@REDACTED
Tue Nov 27 08:35:35 CET 2007
greetings,
i interpret your question to be:
Q: why can register/2 be replaced with erlang:register/2 ?
is that correct?
A: a function without a module prefix can either be a function local to
the module, or it can be a function found in the module ''erlang''.
it helps subsequent readings of the code, and it avoids scooping
problems, if you always explicitly add the erlang module in front of
those functions.
bengt
Those were the days...
EPO guidelines 1978: "If the contribution to the known art resides
solely in a computer program then the subject matter is not
patentable in whatever manner it may be presented in the claims."
On 11/27/07 08:17, LUKE wrote:
> I found that i lose some word in the code.
>
> start(Name,Mod)->register(Name,spawn(fun()->loop(Name,Mod,Mod:init()) end)).
> But
>
> Why the code can be compile?
> start(Name,Mod)->erlang:register(spawn(fun()->loop(Name,Mod,Mod:init())
> end)).
>
>
> ----- Original Message -----
> *From:* LUKE <mailto:luke@REDACTED>
> *To:* erlang-questions@REDACTED <mailto:erlang-questions@REDACTED>
> *Sent:* Tuesday, November 27, 2007 2:50 PM
> *Subject:* What is the function be defined as BIF?
>
> -module(genserver).
> -export([start/2,rpc/2]).
>
> start(Name,Mod)->register(spawn(fun()->loop(Name,Mod,Mod:init()) end)).
> ....
>
> Eshell V5.5.5 (abort with ^G)
> ...
> 9>c(genserver).
> ./genserver.erl:4: function register/1 undefined
>
> --
> modify the register to erlang:register
> start(Name,Mod)->erlang:register(spawn(fun()->loop(Name,Mod,Mod:init())
> end)).
> --
>
> 10> c(genserver).
> {ok,genserver}
>
> The register function is BIF ?
> And the spawn function is BIF?
> All of erlang:* is BIF?
> When we need specify a prefix erlang:* ?
> Why the most of example does not using erlang:register?
>
>
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
More information about the erlang-questions
mailing list