Trouble with init/1 spec

Jay Nelson jay@REDACTED
Wed Mar 24 17:30:56 CET 2010


On Mar 24, 2010, at 9:20 AM, Magnus Henoch wrote:
>
> My favourite fix for that is to pass a tuple instead of a list.
> gen_{server,fsm}:start_link accept any term as the argument, and  
> pass it
> unchanged to the init callback function, so I don't really see any
> reason to use a list there.

Wow!  After all these years, for some reason I always thought init/1  
took a list of args the way {M,F,A} does.  I don't know if I picked  
it up because of all the examples or what, but of course it makes no  
sense that fun/1 could specify the type of the argument.

I always have boiler plate code from start_link/xx to init/1 that  
rebundles all my args as a list.   Doh!

And of course using a tuple follows the OTP coding standard for fixed  
length data structures, as well as utilizing dialyzer the way it was  
intended.

Thanks All!
jay



More information about the erlang-questions mailing list