Calling internal functions - foo::bar() ?

Luke Gorrie luke@REDACTED
Mon Feb 28 23:13:42 CET 2005


I have an Erlang feature request: I'd like to be able to call
unexported functions of modules from the Erlang shell.

For example, if I have a module like:

  a() -> a.
  b() -> b.

Then I would like to be able to do this /just/ in the Erlang shell:

  1> foo::b().

This is intended to /avoid/ seedy bad-software-engineering hacks.

The reasons are:

  Today many people use export_all so that they have a convenient way
  to test internal functions in the shell.

  This has the unfortunate side-effect of letting real modules call
  not-explicitly-exported functions, and that in turn means that
  export-lists can go stale because you don't notice when they're

  To remove 'export_all' is dangerous and it requires you to retest
  your program. (What if you were "accidentally" calling unexported
  functions while testing before?). This sucks because typically the
  time you want to remove export_all is when you've just finished
  testing and you notice it in 'cvs diff' before checkin -- i.e.
  exactly when you don't want to make any changes.

  If you do make the effort to correct your export lists and remove
  your export_all's at some point then later you'll be tempted to put
  them back in while hacking and debugging new versions of your

Personally I think that if I had foo::bar() in the shell then I
wouldn't use export_all anymore. Today I use it in most of my modules.


We have discussed this before in [1]. My memory is that Erik Stenman
posted a followup in which he warmed to the idea and implemented it as
a parse-transform, but maybe it's just my mind rewriting history so
that people agree with me. In either case I'd prefer to have this in
the compiler proper instead of a parse transform.

They have this in Common Lisp and it is used for good as well as evil.
I don't argue that we should add it to the whole language, I think
it'd be enough that it works in the shell.


P.S., who can beat this?

     $ find . -name "*.erl" | wc -l
     $ find . -name "*.erl" | xargs grep '^-compile(export_all)' | wc -l
     $ echo $[ 323 * 100 / 813 ]

More information about the erlang-questions mailing list