What is begin...end in Erlang used for?

block, erlang, expression

Solution

Macros, for example:

-define(M(A, B),
    begin
        C = foo(),
        bar(A, B, C)
    end).

Problem

I just stomped at a `begin...end` in Erlang's documentation (here), but it doesn't give some examples of how it is useful. Looking here in StackOverflow I found two cases where people would be using `begin...end`, both in list comprehensions: - https://stackoverflow.com/a/5645116/979505 - https://stackoverflow.com/a/5141263/979505 But I wonder if there are more of such uses. Can anyone provide another scenario in which a `begin...end` is useful in Erlang? Thanks

Original source

Related problems