Funs are always bound to the code they are initially loaded from. Only name look-ups are affected by code loading AFAICT.<div><br></div><div>This has been a source of exceptions in our previous development, because the first time you load new code, F is still valid, but the second time you load new code, the old code is purged and F is now invalid. Any call to it will generate an exception.</div>
<div><br></div><div>We ended up wrapping our needs for lambdas in a module with state instead. Not the most elegant, but allows us to get "dynamic lambdas." If all you need in the fun is module:function, you can use a tuple for that instead of a fun.</div>
<div><br></div><div>Sincerely,</div><div><br></div><div>jw</div><div><br clear="all"><br>--<br>Americans might object: there is no way we would sacrifice our living standards for the benefit of people in the rest of the world. Nevertheless, whether we get there willingly or not, we shall soon have lower consumption rates, because our present rates are unsustainable. <br>
<br>
<br><br><div class="gmail_quote">On Mon, Jan 16, 2012 at 6:41 AM, Gokul Evuri <span dir="ltr"><<a href="mailto:chandu.gokul138@gmail.com">chandu.gokul138@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<p style="padding-right:0px;padding-left:0px;border-bottom-width:0px;padding-top:0px;text-align:left;border-style:initial;border-color:initial;margin-bottom:1em;padding-bottom:0px;border-top-width:0px;clear:both;vertical-align:baseline;line-height:18px;margin-right:0px;font-size:14px;margin-left:0px;border-right-width:0px;font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;word-wrap:break-word;margin-top:0px;border-left-width:0px;background-image:initial">


so for instance</p><pre style="padding-right:5px;padding-left:5px;border-bottom-width:0px;max-height:600px;padding-top:5px;text-align:left;width:auto;border-style:initial;margin-bottom:10px;border-color:initial;padding-bottom:5px;border-top-width:0px;vertical-align:baseline;line-height:18px;font-size:14px;border-right-width:0px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif;margin-top:0px;border-left-width:0px;background-image:initial">
<code style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;border-left-width:0px;border-style:initial;border-color:initial;vertical-align:baseline;background-image:initial;background-color:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif">f() -> 3.
x() -> F = fun() -> f() end,
       A = f(),
       B = ?MODULE:f(),
       C = F().
</code></pre><p style="padding-right:0px;padding-left:0px;border-bottom-width:0px;padding-top:0px;text-align:left;border-style:initial;border-color:initial;margin-bottom:1em;padding-bottom:0px;border-top-width:0px;clear:both;vertical-align:baseline;line-height:18px;margin-right:0px;font-size:14px;margin-left:0px;border-right-width:0px;font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;word-wrap:break-word;margin-top:0px;border-left-width:0px;background-image:initial">


right after <code style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:1px;padding-right:5px;padding-bottom:1px;padding-left:5px;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;border-left-width:0px;border-style:initial;border-color:initial;vertical-align:baseline;background-image:initial;background-color:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif">F</code> hash been defined, </p>


<p style="padding-right:0px;padding-left:0px;border-bottom-width:0px;padding-top:0px;text-align:left;border-style:initial;border-color:initial;margin-bottom:1em;padding-bottom:0px;border-top-width:0px;clear:both;vertical-align:baseline;line-height:18px;margin-right:0px;font-size:14px;margin-left:0px;border-right-width:0px;font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;word-wrap:break-word;margin-top:0px;border-left-width:0px;background-image:initial">


a new version of code for <code style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:1px;padding-right:5px;padding-bottom:1px;padding-left:5px;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;border-left-width:0px;border-style:initial;border-color:initial;vertical-align:baseline;background-image:initial;background-color:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif">f()</code> is defined as follows </p>


<p style="padding-right:0px;padding-left:0px;border-bottom-width:0px;padding-top:0px;text-align:left;border-style:initial;border-color:initial;margin-bottom:1em;padding-bottom:0px;border-top-width:0px;clear:both;vertical-align:baseline;line-height:18px;margin-right:0px;font-size:14px;margin-left:0px;border-right-width:0px;font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;word-wrap:break-word;margin-top:0px;border-left-width:0px;background-image:initial">


<code style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:1px;padding-right:5px;padding-bottom:1px;padding-left:5px;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;border-left-width:0px;border-style:initial;border-color:initial;vertical-align:baseline;background-image:initial;background-color:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif">f()-> three</code>and loaded. </p>


<p style="padding-right:0px;padding-left:0px;border-bottom-width:0px;padding-top:0px;text-align:left;border-style:initial;border-color:initial;margin-bottom:1em;padding-bottom:0px;border-top-width:0px;clear:both;vertical-align:baseline;line-height:18px;margin-right:0px;font-size:14px;margin-left:0px;border-right-width:0px;font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;word-wrap:break-word;margin-top:0px;border-left-width:0px;background-image:initial">


What would be the value of <code style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:1px;padding-right:5px;padding-bottom:1px;padding-left:5px;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;border-left-width:0px;border-style:initial;border-color:initial;vertical-align:baseline;background-image:initial;background-color:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif">C</code>.</p>
<span class="HOEnZb"><font color="#888888">

<div><br></div>-- <br><b><font face="garamond, serif" size="4">Gokul Reddy Evuri</font>,</b><div><span style="line-height:15px"><i><font face="'comic sans ms', sans-serif" color="#c0c0c0"><b>IT Universitet </b></font></i></span><span style="line-height:15px"><i><font face="'comic sans ms', sans-serif" color="#c0c0c0"><b>Göteborg</b></font></i></span><span style="line-height:15px"><i><font face="'comic sans ms', sans-serif" color="#c0c0c0"><span style="font-weight:bold">,</span></font></i></span></div>


<div><span style="line-height:15px"><em style="font-weight:bold"><span style="font-weight:normal"><font face="'comic sans ms', sans-serif" color="#c0c0c0">Göteborg,</font></span></em></span></div><div><span style="line-height:15px"><em style="font-weight:bold"><span style="font-weight:normal"><font face="'comic sans ms', sans-serif" color="#c0c0c0">Sverige.</font></span></em></span></div>


<br>
</font></span><br>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">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><br></div>