<html><head></head><body bgcolor="#FFFFFF"><div>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. </div><div><br></div><div>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. </div><div><br></div><div>In your position I would use Fred's scheme. The 3-liner beats the complicated recompilation solution 99 times out of 100. <br><br>-Geoff</div><div><br>On 14/08/2012, at 9:20, Tyron Zerafa <<a href="mailto:tyron.zerafa@gmail.com">tyron.zerafa@gmail.com</a>> wrote:<br><br></div><div></div><blockquote type="cite"><div>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. <div>Thus this needs to be generic. I cannot assume that:</div><div>1) All functions within the module are going to be used - transferring code which will not be used will result in useless bandwidth costs.</div>
<div>2) All functions required are within a single module </div><div><br></div><div>I was going to perform a static analysis of the function to be migrated and transfer only the functions it depends on. <br><br><div class="gmail_quote">
On Tue, Aug 14, 2012 at 6:09 PM, Fred Hebert <span dir="ltr"><<a href="mailto:mononcqc@ferd.ca" target="_blank">mononcqc@ferd.ca</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
Why do you want to do this, instead of, for example, just sending
the module to the other node?<br>
<br>
<tt>{Mod, Bin, File} = code:get_object_code(Mod),<br>
rpc:call(Node, code, load_binary, [Mod, File, Bin]).</tt><br>
<br>
or alternatively use rpc:multicall(Nodes) for many nodes and doing
the same.<div><div class="h5"><br>
<br>
<div>On 12-08-14 11:15 AM, Tyron Zerafa
wrote:<br>
</div>
<blockquote type="cite"><br>
Hey Jesse
<div> 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. </div>
<div>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.</div>
<div><br>
</div>
<div><br>
<div class="gmail_quote">On Tue, Aug 14, 2012 at 5:10 PM, Jesse
Gumm <span dir="ltr"><<a href="mailto:gumm@sigma-star.com" target="_blank">gumm@sigma-star.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<p>That sounds like you're looking for</p>
<p>-import(Module, Functions).</p>
<p> <a href="http://www.erlang.org/doc/reference_manual/modules.html" target="_blank">http://www.erlang.org/doc/reference_manual/modules.html</a>
</p>
<p>--<br>
Jesse Gumm<br>
Owner, Sigma Star Systems<br>
<a href="tel:414.940.4866" value="+14149404866" target="_blank">414.940.4866</a> ||
<a href="http://sigma-star.com" target="_blank">sigma-star.com</a> || @jessegumm</p>
<div class="gmail_quote">
<div>
<div>On Aug 14, 2012 9:56 AM, "Tyron Zerafa"
<<a href="mailto:tyron.zerafa@gmail.com" target="_blank">tyron.zerafa@gmail.com</a>>
wrote:<br type="attribution">
</div>
</div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>
<div>
Hey all,
<div> Is there any mechanism in Erlang which I
can use to copy functions from one module to
another? So, if I have module <b>A</b> containing
functions <b>a</b>, <b>b</b> and <b>c</b>, is
there any way in which I can copy <b>a</b> to
module B?<br clear="all">
<div><br>
</div>
<div>Thanks </div>
<div>Tyron</div>
<br>
</div>
<br>
</div>
</div>
_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br>
</blockquote>
</div>
</blockquote>
</div>
<br>
<br clear="all">
<div><br>
</div>
-- <br>
Best Regards,
<div>Tyron Zerafa</div>
<br>
</div>
<br>
<fieldset></fieldset>
<br>
<pre>_______________________________________________
erlang-questions mailing list
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a>
</pre>
</blockquote>
<br>
</div></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>Best Regards,<div>Tyron Zerafa</div><br>
</div>
</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>erlang-questions mailing list</span><br><span><a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a></span><br><span><a href="http://erlang.org/mailman/listinfo/erlang-questions">http://erlang.org/mailman/listinfo/erlang-questions</a></span><br></div></blockquote></body></html>