[erlang-questions] Why do we need modules at all?

Joe Armstrong <>
Tue May 24 13:46:17 CEST 2011


On Tue, May 24, 2011 at 1:21 PM, Tim Watson <>wrote:

> On 24 May 2011 11:39, Bengt Kleberg <> wrote:
> > Greetings,
> >
> > It would be very nice to have module renaming/namespacing that allowed
> > me to do the following:
> > The modules "misc_lib" and "misc_lib_helper" from developer A should be
> > able to call each other with their original names.
> > The modules "misc_lib" and "misc_lib_helper" from developer B should be
> > able to call each other with their original names.
> > I should be able to call all 4 at the same time with names that I have
> > create/renamed.
> >
> > So, I need to load modules as a set/application/??? that renames them
> > outside of that set (it would be ok to have the same prefix added to all
> > of them), and still allows the files in the set/application/??? to keep
> > using to the old names.
> >
> >
>
> I was thinking about this in terms of some kind of special -import or
> -alias directive. I think it's possible to do just with a
> parse_transform, as long as the set can be fully determined at compile
> time. That last point though - therein lies the rub. App-upgrades
> change things, and those things can include modules. Dragons.
> Nuff-said.
>

It depends upon what -import means.

-import(foo,  [bar/2 ]).

Where are two interpretations

a)  "when you *run* this program and find a call to foo:bar/2 go and see if
you can find the code
for foo, load it then call the function bar/2"

b ) "When you *compile* this program find the code for foo:bar/2 and
extract the code for bar/2 and include it in my code" - in this case you
resolve the name at compile time.

I guess when developing a) is useful but when you deploy code it should be
b)

/Joe






> _______________________________________________
> erlang-questions mailing list
> 
> http://erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20110524/621eb05a/attachment.html>


More information about the erlang-questions mailing list