[erlang-questions] new new in parameterized modules causes beam_dead

Mikael Karlsson karlsson.rm@REDACTED
Sat Mar 13 13:04:07 CET 2010


Thank you for the info Richard,
while having the attention of the originator:
1.
Are there any documentation on parameterized modules more than
http://www.erlang.se/euc/07/papers/1700Carlsson.pdf
and
http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.58.79&rep=rep1&type=pdf
More like a spec or so and (maybe) updated for any changes?

2.
I like that the new function return the module like a tuple, it makes it
almost lika a dual nature of records and it makes it very easy to write
setter functions in the module:
-module(test,[A,B,C,D,E,F,G,H,I,J]).
-record(test,{a,b,c,d,e,f,g,h,i,j}).  %% record specification local in
module (no includes)
-export([set/2]).

set(a,V) -> setelement(2,THIS,V);
%% or
set(b,V) -> THIS#test{b=V};
etc...

Is this tuple format something that can be considered future proof in the
implementation of parameterized modules?

Cheers
Mikael

2010/3/12 Richard Carlsson <carlsson.richard@REDACTED>

> Mikael Karlsson wrote:
>
>> Yes,
>> I just figured out what the problem is.
>>
>> In my new "new" function I call another function which I defined in my
>> module:
>>
>> helper_fun(X) -> xxx.
>>
>> new(Z) ->
>>  A = helper_fun(Z),
>>  ...
>>  intance(X,Y,Z1).
>>
>> This does not work.
>> It seems that other funs can only be called from an instanciated module,
>> like:
>> ..
>>  M1 = mod1:new(Z),
>>  M1:helper_fun(X),
>> ..
>>
>> Works OK after removing internal calls.
>>
>> /Mikael
>>
>
> Yes, those extra functions will not be "static" like new/1. However,
> the compiler shouldn't crash like that. Thanks for reporting it.
>
>    /Richard
>


More information about the erlang-questions mailing list