[erlang-questions] Why do we need modules at all?

Edmond Begumisa <>
Wed May 25 09:28:51 CEST 2011


On Wed, 25 May 2011 17:11:48 +1000, Bengt Kleberg  
<> wrote:

> Moreover, to solve the problem this should work for two different beam
> modules, having the same name, being used at the same time. Since they
> are already compiled we must do the mapping outside of the modules.
>
>
> bengt
>

Yes, in my second suggestion the mappings would be outside the modules, in  
a single "manifest" file. This idea comes from the way "chrome.manifest"  
and the "chrome://" URI works in Mozilla (those who've written  
Firefox/Thunderbird extensions would be familiar with it.)

The code loader would have to consult the manifest file for the "real"  
locations of the modules. That's what I was trying to describe here...

> 2. Expanding on this: letting the programmer centralise the possible  
> locations of modules/functions and use this to define namespaces...
>
> One possible way of doing this is to steal from the "chrome  
> registration" system that the Mozilla Framework uses. A programmer could  
> define one-level deep namespaces in a configuration file which points to  
> targets that could come from anywhere, then use that in her modules. A  
> module could then start...
>
> -import(["erlang://misc/collect_int", "erlang://couch/mapreduce"]).
>
> Where "misc" and "couch" are namespaces and "erlang://" is a special URI  
> scheme telling the code loader to refer to the configuration file  
> "erlang.manifest" which would contain...
>
> [{"misc", "file://./ebin/misc.beam"},
>   {"couch", "http://localhost:7777/ebin/"}]
>
> Where "couch" points to a yaws server serving couch beams, or something  
> along those lines. Then she can easy switch between different code  
> sources using one file.
>
> A code-signing system could also be introduced.
>

- Edmond -


> On Wed, 2011-05-25 at 09:07 +0200, Richard O'Keefe wrote:
>> On 25/05/2011, at 3:34 PM, Edmond Begumisa wrote:
>>
>> > Hello Joe,
>> >
>> > I've personally wanted an easy way to load modules from different  
>> places.
>> >
>> > If you started with making modules easy to load from different  
>> places, then later provide support for functions, I imagine this would  
>> be easier to implement immediately and easier for people to make use of  
>> immediately ... where "people" refers to me :)
>> >
>> > I've got two suggestions (mostly inspired by the Mozilla Framework)...
>> >
>> > 1. How about letting the programmer choose where the functions come  
>> from (kv store, fs, web-server, etc)...
>> >
>> > For instance, a module could start...
>> >
>> > -import(["file://misc/collect_int", "http://erlang.org/lists/*",  
>> "mnesia://db1/misc/merge_kv"]).
>>
>> Why does this have to be done inside the module?
>> Why cannot the mapping from module names to sources
>> be *outside*, like an SGML (or XML) catalogue,
>> or a .lace file?
>>
>>
>> _______________________________________________
>> erlang-questions mailing list
>> 
>> http://erlang.org/mailman/listinfo/erlang-questions
>
> _______________________________________________
> erlang-questions mailing list
> 
> http://erlang.org/mailman/listinfo/erlang-questions


-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/



More information about the erlang-questions mailing list