[erlang-questions] Drive by mention of new features without explaination
Sverker Eriksson
sverker@REDACTED
Tue Dec 8 11:37:39 CET 2009
Björn Gustavsson wrote:
> Therefore, I suggest the following change for R13B04:
>
> The on_load function must return 'ok' if the function is to remain loaded.
>
> Returning any other value (or causing an exception) will cause the
> module to be unloaded.
> In addition, if the return value is {error,Anything}, a message will
> be written to the error_logger.
>
>
Actually load_nif returns {error, ReasonAtom, ReasonText} where the atom
is "matchable" and the text human readable. Would it be better with
{error, {Atom,Text}} maybe?
And right now I recommend matching against 'ok' which will get you that
error tuple in the face, at least when playing in the shell:
on_load() ->
ok = load_nif("./niftest", 0),
true.
1> niftest:hello().
=ERROR REPORT==== 8-Dec-2009::11:01:37 ===
Error in process <0.35.0> with exit value:
{{badmatch,{error,load_failed,"Failed to load NIF library ./niftest:
'./niftest.so: cannot open shared object file: No such file or
directory'"}},
** exception error: undefined function niftest:hello/0
2>
/Sverker, Erlang/OTP Ericsson
More information about the erlang-questions
mailing list