[erlang-questions] import/1
Robert Virding
rvirding@REDACTED
Mon Jun 8 17:57:10 CEST 2009
When using import you have to explicitly state which functions you are
importing from a module. The compiler should complain here but I guess it is
interpreting it as
-import(foo, []).
i.e. import no functions from foo.
Note that import does very little! All it does is to implicitly add the
module when calling an imported function. So after doing
-import(foo, [bar/1]).
a call to bar, for example bar(42), will be expanded to foo:bar(42). That is
all. It has no semantic meaning, or checks, or looking up the module, or
anything. It only saves some typing. This why you have to explicitly state
which functions to import.
Personally I only use it for importing functions from some very basic
modules like lists.
Robert
2009/6/8 Joel Reymont <joelr1@REDACTED>
> Is there a particular reason why -import(foo). does not work?
>
> The compiler does not complain but no functions seem to be imported.
>
> Thanks, Joel
>
> ---
> Mac hacker with a performance bent
> http://www.linkedin.com/in/joelreymont
>
>
> ________________________________________________________________
> erlang-questions mailing list. See http://www.erlang.org/faq.html
> erlang-questions (at) erlang.org
>
>
More information about the erlang-questions
mailing list