[erlang-questions] -import/1 and R16
Fri Mar 22 17:22:26 CET 2013
From what I understood, the attribute -import/1 was never meant to import
all functions from an external module, but to import a package-qualified
module into the current package namespace. So -import(erlang.lang.list).
would have made every function from erlang.lang.list module available
through the name list.
The removal of packages and thus -import/1 is explicitly mentioned in
the R16A changelog :
OTP-10348 The experimental support for packages has been removed.
You can see both the old and new behaviour in the related compiler commit .
Notice there was no machinery in sys_pre_expand.erl to handle -import/1
attributes as you describe (at least from what I gather by reading the code).
Le 22 mars 2013 à 17:09, Roberto Aloi a écrit :
> 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:
> This discourage usage of the `import` attribute, which is a good thing in general. On the other side, there is plenty of legacy code relying on this attribute. Compilation for this code will fail under R16B due to a "bad import declaration".
> There are also some leftover for `-import/1` in the OTP code. As an example, `erl_syntax_lib` stil believes that an atom could be returned by the `attribute_arguments/1` function:
> I'm curious about why this change hasn't been explicitly mentioned in the change-log for R16A/B. Am I missing something obvious?
> Roberto Aloi
> erlang-questions mailing list
More information about the erlang-questions