[erlang-questions] Erlang 3000?

Benjamin Tolputt btolputt@REDACTED
Tue Nov 18 03:48:25 CET 2008


Bob Ippolito wrote:
> I think the problem is that packages were implemented in an
> undesirable way. Erlang does have a package system, but AFIAK nobody
> uses it or likes it.
>
> What I don't like about the package system is that any time you use it
> you need to do a bunch of explicit stuff to use standard modules (e.g.
> -import(list) or something).
>   

For me it would be enough if I could do the following:
------------------

%% File: namespace1.module1.erl
-module(namespace1.module1).

%% Namespace for this file - probable not required if I can simply name
the file appropriately
-namespace(default, namespace1).
-namespace(using, namespace1.module2).

-export([foo/0]).

foo()->
    module2:bar(), %% This will actually use namespace1.module2:bar()
    ok.

------------------

%% File: namespace1.module2.erl
-module(namespace1.module2).

%% Namespace for this file - probable not required if the compiler can
work it out from filename
-namespace(default, namespace1).

-export([bar/0]).

bar()->
    file:get_cwd(). %% As there is no "namespace1.file.erl" module, this
will use the standard file:get_cwd() fun

------------------

This would give standard behaviour for modules not within the namespace
and for where the code never uses the "-namespace(...)" (such as all
existing code).

>From the look of it - it could be implemented simply by replacing any
occurence of "module2" to "namespace1.module2" in the compilation phase.
There are issues with the passing around of atoms though (for example,
say I pass the atom tuple {module2, bar} to code outside the namespace
and it then uses it to call module2:bar - what happens?).

There is a bit of thought needed before this would go ahead, but I don't
think the parties most needed in the discussions are interested in
implementing this at the moment.

-- 
Regards,

Benjamin Tolputt
Analyst Programmer

This email and any files transmitted with it are confidential to the
intended recipient and may be privileged. If you have received this
email inadvertently or you are not the intended recipient, you may not
disseminate, distribute, copy or in any way rely on it. Further, you
should notify the sender immediately and delete the email from your
computer. Whilst we have taken precautions to alert us to the presence
of computer viruses, we cannot guarantee that this email and any files
transmitted with it are free from such viruses.






More information about the erlang-questions mailing list