export_to (Was: Re: the OO metaphor)

Luke Gorrie luke@REDACTED
Mon Aug 6 09:26:34 CEST 2001

Ulf Wiger <etxuwig@REDACTED> writes:

> >Maybe if you use module_info/0 for looking up functions you can get
> >in trouble, but I guess most people only do that for throw-away use
> >in the shell if at all.
> Hehe, I'd like to see some code that actually does something useful by
> calling module info, and then simply going through the list of
> exported functions and calling them, just to see what would happen.

Pardon the late (8 months) reply, but I just found a use for calling
module_info in a program :-)

I have a module that exports a bunch of functions which are the BIFs
of a small embedded language. It also exports another few "meta"
functions which aren't supposed to be callable as BIFs.

So I make a "non_bif_exports()" function containing a [{Name, Arity}]
list of the exported functions that aren't BIFs, then have

  bifs() -> ?MODULE:module_info(exports) -- non_bif_exports().

Which I claim is at least a defensible use of module_info in a real
program :-)


More information about the erlang-questions mailing list