[erlang-questions] -import/1 and R16

Richard Carlsson carlsson.richard@REDACTED
Fri Mar 22 17:39:57 CET 2013


On 2013-03-22 09:09 , Roberto Aloi wrote:
> Hi all,
>
> I have noticed that the behaviour of the `import` module attribute
> slightly changed in R16. Specifically, it's not possible to use the
> `-import/1` variant anymore to import all functions from an external
> module. You need to use the `import/2` variant and to explicitly list
> all function names and their arity:

The declaration -import(M) was part of the experimental 'packages' 
feature which was removed in R16. But -import(foo) did not mean "import 
all functions from foo" (because due to dynamic code loading, this would 
be a very vague concept). It just meant "allow the name foo to be used 
unqualified within this module", so e.g. -import(fee.fie.foo) allowed 
you to write foo:f(X) instead of fee.fie.foo:f(X). The case where the 
imported name has no dots in it, as in -import(lists), simply meant that 
you could say lists:reverse() instead of .lists:reverse() (note the 
leading dot) in order to call modules in the top level package. With 
packages removed, this declaration has no meaning.

     /Richard




More information about the erlang-questions mailing list