[erlang-questions] Question concerning the use of -export

ok <>
Fri Jul 13 02:40:16 CEST 2007


erlang:spawn/3 is outside your module,
so in a call spawn(?MODULE, foo, [.....]) the foo function
_is_ called from outside ?MODULE and therefore has to be
exported.

Several years ago I proposed a form of limited export (inspired by
Eiffel):

     -export_to(Module, [F/N, ..., F/N]).

which would export the named functions to that module only.
In particular,

    -export_to(erlang, [foo/2]).
...
       spawn(?MODULE, foo, [X,Y])

would make it possible to call a function through spawn/3 without
making it visible absolutely everywhere.  (Exporting to the shell
module would also make it possible to call debugging functions
without making them visible everywhere.)  -export_to is particularly
important for applications whose modules need to make stuff available
to each other without making it available outside the application.






More information about the erlang-questions mailing list