[erlang-questions] package namespaces question
Enrique Marcote
mpquique@REDACTED
Wed Nov 11 10:54:58 CET 2009
Hola Angel:
Importing every module explicitly is not the worse thing, actually is even good, and besides that, the alternative (dot notation) is awful. Be warned that tools like dialyzer do not support packages. In our organization dialyzer is a fundamental tool and we prefer to sacrifice packages.
I'm afraid that in the current state, packages will give you more headache than benefits. You may consider using a flat name space and agree on a prefix for every app. In your example you could do something like:
gui.erl (for the application).
gui_sup.erl (supervisor).
gui_top_pane.erl
...
and so on.
It's not the nicest thing, but probably more convenient for the time being.
Saludos,
Enrique
El 10/11/2009, a las 20:58, Angel Alvarez escribió:
> Gracias Enrique!
>
> But how can i import all system modules and apps?
>
> Has gs become lib.gs or something alike?
>
> Well, the URLS from 2004 were bit old ive just found the current version at http://www.erlang.org/doc/man/packages.html
>
> I saw no prior examples of packcages used on the list certainly not back in 2008/2009 so an " almost deprecated" notice at the top
> of the page is all i need to stop at here and continue reading other things....
>
> /Angel
>
> El Martes, 10 de Noviembre de 2009 Enrique Marcote escribió:
>> Hola Angel,
>>
>> Try importing gs.
>>
>> Saludos,
>>
>> Enrique
>>
>>
>> El 10/11/2009, a las 20:10, Angel Alvarez escribió:
>>
>>> 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.
>>>
>>> ________________________________________________________________
>>> erlang-questions mailing list. See http://www.erlang.org/faq.html
>>> erlang-questions (at) erlang.org
>>>
>>
>>
>
>
>
> --
> Agua para todo? No, Agua para Todos.
> ->>-----------------------------------------------
> Clist UAH a.k.a Angel
> ---------------------------------[www.uah.es]-<<--
>
> No le daría Cocacola Zero, ni a mi peor enemigo. Para eso está el gas Mostaza que es mas piadoso.
More information about the erlang-questions
mailing list