[erlang-questions] dialyzer error: apply_op_not_a_variable

Richard Carlsson carlsson.richard@REDACTED
Thu Oct 13 18:33:34 CEST 2011


On 10/13/2011 03:52 PM, Joel Reymont wrote:
> This is the problem
>
> 	({?MODULE, State})(Event, Bot)

This depends on knowing that the current implementation of parameterized 
modules uses the representation {Mod, X1, ...Xn}. Don't create such 
tuples directly: call Mod:new(State) instead.

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:

   -module(mymodule, [X]).

and use the automatic mymodule:new(X) function to instantiate them.

In any case, parameterizing modules on a "state" variable is a pretty 
fishy thing to do. You might want to rethink your approach.

     /Richard



More information about the erlang-questions mailing list