Parameterised modules

Chris Pressey cpressey@REDACTED
Thu Sep 4 19:34:50 CEST 2003

On 04 Sep 2003 11:37:08 +0200
"Lon Willett" <p0rj2el602@REDACTED> wrote:

> And while on the topic of parameterised modules, an issue that I am
> concerned with is the handling of code change.  I am not convinced
> that the proposed handling is correct.  I am not even sure what the
> _right_thing_ is.

As someone who didn't see the talk, forgive me if this is way off base.
But I think I prefer a different approach.  Although I forget exactly
who mentioned it, I think it was one of the gurus who occasionally
posts, during the last round of wish lists.

Instead of parameterized modules, what about full-fledged lambda

Analogous to funs, I'll call them mods.  Also analogous to funs I'll use
the following syntax:

  Mod = mod
    function1(A1, A2) -> something.
    function2(A1, A2) -> something_else.

This way you can 'parameterize' a module like so:

  String = "Hello, world!",
  Mod = mod
    print() -> io:fwrite("~s", [String]).

or, a better example might be

  printing_module(String) ->
      print() -> io:fwrite("~s", [String]).

  whatever() ->
    printing_module("Hello, world!"):print().

The thing is that these wouldn't be subject to code change (just like
funs aren't.)  Also, they might be able to be stored whole cloth in
mnesia tables etc (again just like funs.)  While these properties
wouldn't make them suitable for everything (just like funs aren't,) I
think they would be perfect for certain things (just like funs are.)

They also strike me as much simpler than parameterized modules (from the
programmer's point of view; I'm not really deeply considering how they'd
have to be implemented.)



More information about the erlang-questions mailing list