[erlang-questions] Copy function from one Module to another

Richard O'Keefe ok@REDACTED
Wed Aug 15 01:48:05 CEST 2012


On 15/08/2012, at 3:15 AM, Tyron Zerafa wrote:

> 
> Hey Jesse
>     I need something stronger than just import. I need to put a bunch of functions from different modules into a single one and transfer this to a remote node. Then I want to be able to use these functions from the remote node. 

Never mind a remote node, I just can't see taking a random bunch of functions from
different modules and stuffing them into another module making any kind of sense.

Consider:
  -module(a).
  ..
  f() -> g().
  g() -> 12.

  -module(b).
  ..
  h() -> g().
  g() -> 34.

Now, "put" a:f/0 and b/h:0 into a new module c.
What happens to g?

The only way I can even begin to make sense of this is to construct
the new module thus:
  -module(c).
  -export([f/0,h/0]).
  f() -> a:f().
  h() -> b:h().
and then to provide *all* of the modules.





More information about the erlang-questions mailing list