http://www.erlang.org/news/35 mentioned that this will be documented, but I can't find it in the documentation.
Erlang - Tuples. A tuple is a compound data type with a fixed number of terms. Each term in the Tuple is called an element. The number of elements is said to be the size of the Tuple. An example of how the Tuple data type can be used is shown in the following program. Here we are defining a Tuple P which has 3 terms.
A "tuple module" is a tuple with two elements, the name of a module and a list of extra arguments. For example: Such a tuple can be used instead of a module name in function calls. In this case, the function being called will get the tuple in question as an additional argument at the end of the argument list:
A tuple is a compound data type with a fixed number of terms. Each term in the Tuple is called an element. The number of elements is said to be the size of the Tuple. An example of how the Tuple data type can be used is shown in the following program. Here we are defining a Tuple P which has 3 terms.
With the latest release of Erlang (R21) tuple calls are opt-in. What that means is you have to use a compiler flag to make them usable. I also found discussions about removing it altogether. There is a lot of hate for this particular feature, and I haven’t found any good reason why.
A "tuple module" is a tuple with two elements, the name of a module and a list of extra arguments. For example:
{my_module, [foo, bar]}
Such a tuple can be used instead of a module name in function calls. In this case, the function being called will get the tuple in question as an additional argument at the end of the argument list:
3> Module = {lists, [[foo]]}.
{lists,[[foo]]}
4> Module:append([bar]).
[bar|{lists,[[foo]]}]
This call is equivalent to:
7> lists:append([bar], {lists, [[foo]]}).
[bar|{lists,[[foo]]}]
Tuple modules are kept for backwards compatibility, as they were the implementation mechanism for parameterised modules, which were removed from the language in R16.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With