[erlang-questions] I need to call unexported functions from the erlang shell

ok ok@REDACTED
Mon Jun 18 01:53:40 CEST 2007


On 15 Jun 2007, at 9:23 pm, Thomas Lindgren wrote:
> Fully agreed on the practicalities, and adding a
> '%preserved' or generating a module_info-like function
> for the same functionality is straightforward, but
> does it in practice fix anything substantial beyond
> adding +export_all in the makefiles?

It preserves the distinction between functions which are meant to
be called by other modules and those which are not.  With
-export_all, everything is exported on an equal footing and you
can accidentally call a debugging function as if it were part of
the normal interface.

One important aspect of my proposal was -preserve, not just
preserve_all; making it possible to expose *some* not-normally-
exported functions for debugging purposes without requiring
*all* of the functions to be available.

It would clearly be possible to imitate ISO Pascal Extended,
in which a module may export any number of different interfaces.
This is not a serious proposal, but it is a sketch of how something
like that might go.

	<module> ::=
	    -module.
	    <interface>+
	<interface> ::=
	    -interface(<module name>, <exports>).
	<exports> ::=
	    all
	  | [<functor>, ..., <functor>]

So you might have

	-module.
	-interface(freddo, [croak/0, hop/1]).
	-interface('freddo debug', all).

Even without considering interactive debugging, there are reasons
for distinguishing between the interface a module exports to the
world and the interface it exports to its close associates.




More information about the erlang-questions mailing list