[erlang-questions] lists:reverse/1 as a built-in function

Robert Baruch autophile@REDACTED
Tue Jan 16 18:09:27 CET 2007


BTW, I just realized one problem with my proposal. If I have a module  
bar in package foo (i.e. foo/bar.erl) and a module baz in package  
foo.bar (i.e. foo/bar/baz.erl), you could run into problems when you  
try to -import(foo.bar).

My proposal would not know whether this means you want to import the  
module bar in package foo, or all modules in package foo.bar.

If you're gonna steal from Java, may as well go all the way :)

The modification that would make this work is that -import(foo.bar.*)  
imports all modules in foo.bar, while -import(foo.bar) imports module  
bar from package foo.

And, just like in Java, you have to add a rule to name resolution so  
that if you use a module name which exists in two packages, both of  
which you import, a compile-time error occurs -- you must fully  
qualify the name.

Example:

(assumes that you have module m in package foo.bar and in package baz)

-module(myproject.my_module).
-import(foo.bar.*).
-import(baz.*).

fun(Arg) -> m:do_it(Arg).

This is a compile time error. Does m:do_it refer to foo.bar.m.do_it/1  
or baz.m.do_it/1? You'd have to write either

fun(Arg) -> foo.bar.m:do_it(Arg).

or

fun(Arg) -> baz.m:do_it(Arg).

depending on which m you wanted.


--Rob




More information about the erlang-questions mailing list