[erlang-questions] Why do we need modules at all?
Tim Carpenter
amphibian.ltd@REDACTED
Tue May 24 12:03:53 CEST 2011
Hi all,
I am sticking to the request to not comment on other solutions but
present my own thoughts...
1. Some units of code only make sense as a collection. who would use
part of gen_server in isolation? Well, you could,but to have it
separate exposes it to modification that could distort the focused
purpose of the unit.
2. some functions have intentionally hidden aspects, private calls etc
and these again are best left hidden or considered as a logical whole
otherwise side effects or bloat may occur.
3. I see no reason why we cannot logically group functions into
modules but not have the code in there...i.e. the module contains the
references to functions that make it up. this allows logical handling
of groups of functions for code management and can allow one function
to appear in multiple modules without code duplication. it also allows
one to add/delete/replace a function in a module knowing that the
source code for the other functions have not been touched!
4. naming conventions should be given great thought for simplicity and
intuitiveness. functions could be in n sets, so a strict hierarchy may
not suit.
5. if functions are named as being in modules, the need to provide
abstraction to the full name may be advantageous, so modulename.sort/3
can be used and the module definition translates this to a unique
longhand which can change over time. The programmer should also be
able to use the longhand at will using the module as a convenient bulk
import/compile vehicle that will break at compile time (one would
hope). Some form of 'expects...' notation could allow a form of
protection against inadvertent swapping of functions in shared modules
altering behaviour.
6. we may want 3 elements to naming of functions: shorthand, longhand,
and version, so one can use the latest version of a longhand named
function, lock to a specific version of a longhand named function or
use the shorthand latest version or other such combinations.
7. n- tier modules - modules of modules? possibly.
Tim
On 24 May 2011, at 10:05, Kresten Krab Thorup wrote:
> Sorry, my mail got strangled in flight. Here we go again... in
> plain text.
>
> The gen_server module is used for three different things:
>
> - as a collection of API function (left)
> - a place to put the code that controls the gen_server process
> (middle)
> - a place to describe the abstract notion of a gen_server behavior
> (right).
>
> Ideally, I think those three usages should be separate language
> constructs, but probably not in separate files (or other kinds of
> units).
>
> When using a gen_server, it would be nice if you did not have to
> expose the behavior api to the "user" of your module.
>
>
> Currently, the module is the unit of code loading. I think we could
> use a bette mechanism, perhaps one that supports an STM-like thing
> in the VM to control the loading of a set of modules. I don't have
> much deep experience with code loading in Erlang (but do have it on
> Java), and it just seems to me that being able to control atomic
> loading of .. say a new version of an Erlang application would be
> good to have supported in the VM.
>
>
> Gilad Bracha (who's working on Newspeak) has an excellent blog on
> new notions of modues that you should read. You can start here http://gbracha.blogspot.com/2009/06/ban-on-imports.html
>
> One of the things he's arguing is that modules should be VALUES. A
> "module" in newspeak is kind of a template (function), which take
> other module instances as arguments. So you hook up a system by
> applying such templates (possibly using letrec).
>
>
> If we had a visual programming environment, then many things don't
> need a name. Self is an example of this (Self, the video: http://video.google.com/videoplay?docid=5776880551404953752#)
>
> Kresten
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
Tim Carpenter
Amphibian Ltd
London
ENGLAND
+44(0)7900 888826
amphibian.ltd@REDACTED
More information about the erlang-questions
mailing list