Erlang/OTP Forums

Author Message

<  Erlang patches mailing list  ~  packages and forgotten imports

etxuwig at etxb.ericsson.
Posted: Thu Apr 17, 2003 3:19 pm Reply with quote
Guest
I've been playing around with packages in Erlang for a
while, and must say that it happens annoyingly often that I
forget to insert 'import' clauses for OTP modules that I
want to use.

The standard Erlang problem of calling undefined external
functions is usually not a very big one, IMHO, but it
becomes decidedly more common with packages due to the
legacy treatment of "the empty package".

A suggestion: if a module with a package name is compiled,
the linter could issue a warning if an implicitly named
module is not found in the 'outdir'.

It's not difficult to order modules in the Makefile so that
compilation is done in dependency order; this has to be done
anyway if one defines custom behaviours or parse transforms
(I know, that doesn't happen every day.)

I've attached a suggested patch to erl_lint.erl.

Given the following test module (test.erl):

-module(mypackage.test).

-export([foo/0]).
%% forgotten -import(lists).

foo() ->
lists:foldl(fun(X,A) -> [X|A] end, [], [a,b,c]).




1> compile:file(test,[{outdir,"../ebin"},return_warnings]).
{ok,'mypackage.test',

[{"./test.erl",[{7,erl_lint,{maybe_missing_import,"lists"}}]}]}
42> compile:file(test,[{outdir,"../ebin"},report_warnings]).
./test.erl:7: Warning: Missing import for module lists
{ok,'mypackage.test'}


/Uffe
--
Ulf Wiger, Senior Specialist,
/ / / Architecture & Design of Carrier-Class Software
/ / / Strategic Product & System Management
/ / / Ericsson AB, Connectivity and Control Nodes



Post generated using Mail2Forum (http://m2f.sourceforge.net)

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum