[erlang-questions] Modules and function "encapsulation"

Ulf Wiger ulf.wiger@REDACTED
Wed Sep 1 08:33:41 CEST 2010

On 01/09/2010 06:16, Silas Silva wrote:
> On Wed, Sep 01, 2010 at 12:57:24PM +0900, Geoffrey Biggs wrote:
>> Generally, you shouldn't use the -import statement. Call functions from
>> other models explicitly using the model:function syntax (such as
>> controller:start()). Using -import makes the code harder to follow and,
>> as you discovered, leads to name clashes.
>> Geoff
> Thank you!  I didn't realize I could use other modules functions without
> -import'ing them...  That is because I was getting name clashes.
> Thanks.

As implied in that thread, what -import does is that it lets you
call a remote function just as if it were a local function or a BIF.

E.g. using

-import(lists, [reverse/1]).

I can write reverse(L) rather than lists:reverse(L), but it is purely
a syntactical convenience, and as you discovered, knows nothing of

The EUC talk mentioned, by Richard Carlsson, has been implemented as
an experimental feature. http://www.trapexit.org/Extend_Module

Note the experimental status. This is not to say it doesn't work -
I daresay it does - but that there is no commitment to keep the
feature as-is.

Ulf W
Ulf Wiger
CTO, Erlang Solutions Ltd, formerly Erlang Training & Consulting Ltd

More information about the erlang-questions mailing list