[erlang-questions] -import/1 and R16

Anthony Ramine <>
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 [1]:

	   OTP-10348  The experimental support for packages has been removed.

You can see both the old and new behaviour in the related compiler commit [2].
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).


[1] http://www.erlang.org/download/otp_src_R16A_RELEASE_CANDIDATE.readme
[2] https://github.com/erlang/otp/commit/f143990aea3ed5dd62952c1ed3d0a052f011626f

Anthony Ramine

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:
> http://www.erlang.org/doc/reference_manual/modules.html
> 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:
> https://github.com/erlang/otp/blob/maint/lib/syntax_tools/src/erl_syntax_lib.erl#L1537
> I'm curious about why this change hasn't been explicitly mentioned in the change-log for R16A/B. Am I missing something obvious?
> Cheers,
> -- 
> Roberto Aloi
> ---
> _______________________________________________
> erlang-questions mailing list
> http://erlang.org/mailman/listinfo/erlang-questions

More information about the erlang-questions mailing list