Tuple Modules

When we call M:f(Arg1, Arg2, ..., ArgN), we have assumed that M is a module name. But M can also be a tuple of the form {Mod1, X1, X2, ... Xn}, in which case the function Mod1:f(Arg1, Arg2, ..., Arg3, M) is called.

This mechanism can be used to create “stateful modules,” which is discussed in Stateful Modules, and to create “adapter patterns,” discussed in Adapter Patterns.

Get Programming Erlang, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.