Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Copy function from one Module to another
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  9 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Tyron Zerafa  
View profile  
 More options Aug 14 2012, 10:56 am
From: Tyron Zerafa <tyron.zer...@gmail.com>
Date: Tue, 14 Aug 2012 16:56:19 +0200
Local: Tues, Aug 14 2012 10:56 am
Subject: [erlang-questions] Copy function from one Module to another

Hey all,
    Is there any mechanism in Erlang which I can use to copy functions from
one module to another? So, if I have module *A* containing functions *a*, *b
* and *c*, is there any way in which I can copy *a* to module B?

Thanks
Tyron

_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jesse Gumm  
View profile  
 More options Aug 14 2012, 11:10 am
From: Jesse Gumm <g...@sigma-star.com>
Date: Tue, 14 Aug 2012 10:10:39 -0500
Local: Tues, Aug 14 2012 11:10 am
Subject: Re: [erlang-questions] Copy function from one Module to another

That sounds like you're looking for

-import(Module, Functions).

http://www.erlang.org/doc/reference_manual/modules.html

--
Jesse Gumm
Owner, Sigma Star Systems
414.940.4866 || sigma-star.com || @jessegumm
On Aug 14, 2012 9:56 AM, "Tyron Zerafa" <tyron.zer...@gmail.com> wrote:

_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tyron Zerafa  
View profile  
 More options Aug 14 2012, 11:15 am
From: Tyron Zerafa <tyron.zer...@gmail.com>
Date: Tue, 14 Aug 2012 17:15:15 +0200
Local: Tues, Aug 14 2012 11:15 am
Subject: Re: [erlang-questions] Copy function from one Module to another

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.
If I simply use import, I will not be able to use them on the remote node
without explicitly transferring all the modules to which the functions
belong to.

--
Best Regards,
Tyron Zerafa

_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Siraaj Khandkar  
View profile  
 More options Aug 14 2012, 11:25 am
From: Siraaj Khandkar <sir...@khandkar.net>
Date: Tue, 14 Aug 2012 11:25:30 -0400
Local: Tues, Aug 14 2012 11:25 am
Subject: Re: [erlang-questions] Copy function from one Module to another
How about sending a message with a fun? Or collecting desired funs in
a record and sending that?

_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tyron Zerafa  
View profile  
 More options Aug 14 2012, 11:28 am
From: Tyron Zerafa <tyron.zer...@gmail.com>
Date: Tue, 14 Aug 2012 17:28:32 +0200
Local: Tues, Aug 14 2012 11:28 am
Subject: Re: [erlang-questions] Copy function from one Module to another

I was thinking about the latter where I will collect all functions in a
record and send that.
The problem is that I will have to come up with a way to extract a function
form a module, that is why I was checking out whether there is anything
already implemented in Erlang.

On Tue, Aug 14, 2012 at 5:25 PM, Siraaj Khandkar <sir...@khandkar.net>wrote:

--
Best Regards,
Tyron Zerafa

_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Fred Hebert  
View profile  
 More options Aug 14 2012, 12:09 pm
From: Fred Hebert <monon...@ferd.ca>
Date: Tue, 14 Aug 2012 12:09:38 -0400
Local: Tues, Aug 14 2012 12:09 pm
Subject: Re: [erlang-questions] Copy function from one Module to another

Why do you want to do this, instead of, for example, just sending the
module to the other node?

{Mod, Bin, File} = code:get_object_code(Mod),
rpc:call(Node, code, load_binary, [Mod, File, Bin]).

or alternatively use rpc:multicall(Nodes) for many nodes and doing the same.

On 12-08-14 11:15 AM, Tyron Zerafa wrote:

_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tyron Zerafa  
View profile  
 More options Aug 14 2012, 12:20 pm
From: Tyron Zerafa <tyron.zer...@gmail.com>
Date: Tue, 14 Aug 2012 18:20:20 +0200
Local: Tues, Aug 14 2012 12:20 pm
Subject: Re: [erlang-questions] Copy function from one Module to another

I want to implement code migration where a user just will be able to call
migrate(RemoteNode, Fun) and that local fun will end up on the RemoteNode.
Thus this needs to be generic. I cannot assume that:
1) All functions within the module are going to be used - transferring code
which will not be used will result in useless bandwidth costs.
2) All functions required are within a single module

I was going to perform a static analysis of the function to be migrated and
transfer only the functions it depends on.

--
Best Regards,
Tyron Zerafa

_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Geoff Cant  
View profile  
 More options Aug 14 2012, 2:01 pm
From: Geoff Cant <n...@erlang.geek.nz>
Date: Tue, 14 Aug 2012 11:01:25 -0700
Local: Tues, Aug 14 2012 2:01 pm
Subject: Re: [erlang-questions] Copy function from one Module to another

You won't be able to do exactly what you have asked for as functions only exist inside modules. Even funs are just context plus a reference to code in a module. You cannot run a fun on a node that doesn't have the module it references.

While I'm sure that Fred's idea is the best (you'd have to be sorely bandwidth constrained before other trade offs make sense) the middle ground would be to compile a new module with just the function + deps you want to migrate and send that to the remote node. You would probably need debug_info in the original module for this to work.

In your position I would use Fred's scheme. The 3-liner beats the complicated recompilation solution 99 times out of 100.

-Geoff

On 14/08/2012, at 9:20, Tyron Zerafa <tyron.zer...@gmail.com> wrote:

_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Richard O'Keefe  
View profile  
 More options Aug 14 2012, 7:48 pm
From: "Richard O'Keefe" <o...@cs.otago.ac.nz>
Date: Wed, 15 Aug 2012 11:48:05 +1200
Local: Tues, Aug 14 2012 7:48 pm
Subject: Re: [erlang-questions] Copy function from one Module to another

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.

_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »