[erlang-questions] about the use of parametrized modules

Jachym Holecek freza@REDACTED
Sat Jan 15 19:49:13 CET 2011


# Max Lapshin 2011-01-15:
> I can tell why I use parameterized modules in erlyvideo.
> 
> This is list of module chain, where functions are called:
> 
> {rtmp_handlers, [apps_login, apps_streaming]}.
> 
> rtmp_session is calling in such manner:  Module:connect(Session, Funcall)
> 
> Now we need a configurable module:  auth_users_limit. It requires
> somehow to store additional configuration variable: limit of users.
> The easies solution for me seems to store it as a parameter for module:
> 
> {rtmp_handlers, [{auth_users_limit, 100}, apps_login, apps_streaming]}
> 
> After that nothing is changed in rtmp_session:
> Module:connect(Session, Funcall), but Module now is just a tuple from
> config: {auth_users_limit, 100}.
> 
> It happened to be very convenient.

The general point aside for a moment, making such a strong assumption about
internal representation of parametrized modules seems like a very curageous
attitude indeed ;-). Unless, of course, such a promise is made explicitely,
like is done with record syntax. Whether that's the case or not I couldn't
tell -- the PM paper only seems to be "available" from the ACM Borg Cube.

Regards,
	-- Jachym


More information about the erlang-questions mailing list