[erlang-questions] basic import for code reuse

Robin robi123@REDACTED
Thu Dec 6 04:41:55 CET 2007

This is a simple example using -import:

member() -> template.

-import(lw_template, [member/0]).
member() -> special.

When I import member/0 and then override it, the compiler gives the

lw_special.erl: defining imported function member/0

When I call member/0, the runtime bombs with an error:

Eshell V5.5.5  (abort with ^G)
1> ls_special:member().
** exited: {undef,[{ls_special,member,[]},
                   {shell,eval_loop,3}]} **

Import followed by override does not work above, so how else can you
specialize an imported function at compile time?

If the runtime bombs from overriding a function, then should the
compiler produce an error rather than just a warning?



More information about the erlang-questions mailing list