[erlang-questions] dialyzer error: apply_op_not_a_variable
Jon Watte
jwatte@REDACTED
Thu Oct 13 21:52:00 CEST 2011
In this context: what is the validity of funs in terms of code reloading?
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.
Sincerely,
jw
--
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.
On Thu, Oct 13, 2011 at 9:54 AM, Richard Carlsson <
carlsson.richard@REDACTED> wrote:
> On 10/13/2011 06:36 PM, Joel Reymont wrote:
>
>>
>> On Oct 13, 2011, at 5:33 PM, Richard Carlsson wrote:
>>
>> On 10/13/2011 03:52 PM, Joel Reymont wrote:
>>>
>>>> This is the problem
>>>>
>>>> ({?MODULE, State})(Event, Bot)
>>>>
>>>
>>> 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:
>>>
>>
>>
>> All I'm doing is ?MODULE:State(Event, Bot)
>>
>
> 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).
>
> If the format of your function call is indeed ?MODULE:State(Event, Bot)
> then there should be no problem (assuming State is an atom).
>
> If you need to pass around the {?MODULE, State} as in your first example,
> then use Fun=erlang:make_fun(**ModuleName, FunctionName, 2). This lets you
> call Fun(Event, Bot) at the place that gets Fun.
>
> (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.)
>
> /Richard
>
> ______________________________**_________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/**listinfo/erlang-questions<http://erlang.org/mailman/listinfo/erlang-questions>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20111013/30ac5b73/attachment.htm>
More information about the erlang-questions
mailing list