[erlang-questions] Parameterized module initialization

Richard Carlsson carlsson.richard@REDACTED
Tue Jun 26 22:36:00 CEST 2012

On 06/26/2012 10:09 PM, Fred Hebert wrote:
> The problem I have with all of these things is that parametrized modules
> will automatically mess up with the arities of function when they're
> perceived and used. This means most tracing is going to be wrong.
> I can't trace on {PMod, Fun, Arity} where PMod is a parametrized module,
> because the current underlying representation ({Mod, Data}) isn't
> accepted by tools such as dbg.
> I can't trace on {Mod, Fun, Arity} where Mod is the actual module I
> think I use, because the Arity is expanded by PMods to pass hidden
> arguments.
> What I actually need to do is {Mod, Fun, Arity+1} while knowing what I
> have is a parametrized module. Messing with arity is not something I'm a
> fan of. I'm also not sure what impact we have when using PMods and the
> fun M:F/A expression, but I can already say it isn't obvious if I should
> expect it to break or not.
> They can be an abstraction, but at best they're a leaky one that can be
> rather confusing when using well known and supported tools.
> I have no solution to offer, though.

Yes, in the current, proof-of-concept implementation, there are a bunch 
of weird effects like this. In a full blown implementation, other tools 
should be taught to recognize parameterized modules (I think they 
currently get the attribute 'abstract'=true) and handle them 
appropriately, so that the arities are presented as they look in the 
source code, not as they are implemented under the hood.


More information about the erlang-questions mailing list