3 ms·
That's why erlang has file:consult from the start. It just reads whatever data is in file, that data can be any valid erlang terms. That format is also used for
by yetihehe 6y ago
That's why erlang has file:consult from the start. It just reads whatever data is in file, that data can be any valid erlang terms. That format is also used for typical system configuration files. Of course, you could make execution based on that configuration file, it happens that erlang already has "standardised" way of storing this as {M,F,A} (module, function, args), which you could send directly to apply:
{ok,Commands}=file:consult("functions.txt"),
[ apply(M,F,A) || {M,F,A} <- Commands ].
With contents of functions.txt:
{io,format,["Hello World!~n"]}.