[erlang-questions] lists:reverse/1 as a built-in function
Tue Jan 16 18:25:14 CET 2007
--- Robert Baruch <> wrote:
> If example_function/1 is imported into module m,
> then it must be
> imported from some module X. Then you must call X's
> 1 as X:example_function/1, and m's function would
> just be called as
> example_function/1. The names would not clash
> because they exist in
> different namespaces.
Well, one might think so. (I for one think the
language should behave that way: local definitions
hide enclosing ones with the same name.) But currently
the result depends on whether example_function is
explicitly imported or auto-imported.
So, to recapitulate: example_function is locally
defined and also imported.
1. If example_function is explicitly imported (with
-import), we get a compilation error. (Apparently,
this is seen as a name clash that can't be resolved.)
f(X) -> g(X).
g(X) -> X.
2. If example_function is auto-imported, we get a
compiler warning, and the call will invoke the BIF,
not the local function. (The name clash is resolved
"the wrong way")
f(X) -> element(1,X).
element(A,X) -> X.
8:00? 8:25? 8:40? Find a flick in no time
with the Yahoo! Search movie showtime shortcut.
More information about the erlang-questions