package namespaces question
Angel Alvarez
clist@REDACTED
Tue Nov 10 20:10:13 CET 2009
Hi Guys!
Im currently reading erlang archives from 2004
On 10/05/2004 Someone talked about package namespaces ("Is erlang too small" thread) so i decided to just test this "new2 erlang knowledge.
iv just borrowed some little code from a gs article... :-)
the module starts like this:
-module(gui).
-export([init/0]).
init() ->
S = gs:start(),
Win = gs:create(window, S, [{width, 350}, {height, 100}]),
gs:create(button, quit, Win, [{label, {text, "Quit"}}, {x, 0}]),
...
so on the erlang shell gui:init(). just runs the example..
So i changed the module to use package style names...
-module(angel.tests.gui).
-export([init/0]).
init() ->
S = gs:start(),
Win = gs:create(window, S, [{width, 350}, {height, 100}]),
gs:create(button, quit, Win, [{label, {text, "Quit"}}, {x, 0}]),
...
and moved the gui.erl to $PWD/angel/test/gui.erl
> sinosuke@REDACTED:~/Datos/Docs/Personal/Erlang/Code/angel/test> erlc gui.erl
> cd ../../
> sinosuke@REDACTED:~/Datos/Docs/Personal/Erlang/Code/
but now firing at the shell results in :
sinosuke@REDACTED:~/Datos/Docs/Personal/Erlang/Code> erl
Erlang R13B01 (erts-5.7.2) [source] [rq:1] [async-threads:0] [hipe] [kernel-poll:false]
Eshell V5.7.2 (abort with ^G)
1> angel.test.gui:init().
** exception error: undefined function 'angel.test.gs':start/0
in function 'angel.test.gui':init/0
What's wrong?
Is needed the same convention on the rest of modules
after you start using package name styles?
From http://www.erlang.se/publications/packages.html
"m2:g(X) becomes a call to foo.bar.m2
If this is not what was intended, the call can be written explicitly, as in
-module(foo.bar.m1).
-export([f/1]).
f(X) -> fee.fie.foe.m2:g(X)."
it seems bit embarrasing, i think is why perhaps no one is using this feature 5 years later...
Thanks Angel
--
No imprima este correo si no es necesario. El medio ambiente está en nuestras manos.
->>-----------------------------------------------
Clist UAH a.k.a Angel
---------------------------------[www.uah.es]-<<--
Tú lo compras, yo lo copio. Todo legal.
More information about the erlang-questions
mailing list