In this context: what is the validity of funs in terms of code reloading?<div><br></div><div>Specifically, if I define a fun and hang on to it "for a long time," I generally find that code reloading to the point where I purge the code that initially defined the fun, will cause an exception the next time that fun is invoked. If this is actual and intended behavior, then I think I also understand why it should be so.</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 Thu, Oct 13, 2011 at 9:54 AM, Richard Carlsson <span dir="ltr"><<a href="mailto:carlsson.richard@gmail.com">carlsson.richard@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On 10/13/2011 06:36 PM, Joel Reymont wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
On Oct 13, 2011, at 5:33 PM, Richard Carlsson wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 10/13/2011 03:52 PM, Joel Reymont wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
This is the problem<br>
<br>
({?MODULE, State})(Event, Bot)<br>
</blockquote>
<br>
If your snippet above is literally what's in your code, then you're doing something even stranger: having a module create an instance of itself (the tuple) and then call a function on that instance. Don't abuse the current underlying mechanism - if you want to use parameterized modules, then declare them as such:<br>
</blockquote>
<br>
<br>
All I'm doing is ?MODULE:State(Event, Bot)<br>
</blockquote>
<br></div>
Ugh, sorry for the noise, I misread. Yes, you're using an "old-style fun", not a parameterized module. (They have the same kind of representation).<br>
<br>
If the format of your function call is indeed ?MODULE:State(Event, Bot) then there should be no problem (assuming State is an atom).<br>
<br>
If you need to pass around the {?MODULE, State} as in your first example, then use Fun=erlang:make_fun(<u></u>ModuleName, FunctionName, 2). This lets you call Fun(Event, Bot) at the place that gets Fun.<br>
<br>
(It would be nice if you could just say Fun=fun M:F/A, where M, F, and A are variables, but the language doesn't support that yet, so you can only use that syntax if M, F, and A are constant literals.)<br><font color="#888888">
<br>
/Richard</font><div><div></div><div class="h5"><br>
______________________________<u></u>_________________<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/<u></u>listinfo/erlang-questions</a><br>
</div></div></blockquote></div><br></div>