What use is `case` sneak- binding?

Michael P. empro2@REDACTED
Wed Aug 18 14:04:10 CEST 2021


What use is the sneaky "slot-machine" nature of
how `case` treats pattern unboundies

Does it simplify the implementation of `case`?

OC, `case` has to _try_ to match the patterns and cannot
simply dump every new binding. Unbinding on badmatch or
repeating the matching or transferring new bindings
after success in some subscope might complicate
the implementation. And sounds a bit like backtracking,
and Erlang was designed with a 'no backtracking' premise ...
yet there cannot be any side-effects as the only expression
allowed in patterns is 'variables', the `case` switch
is evaluated only once anyway ... and now I have shipped
off the brink of my tiny world.

Giving `case` the '(let)' after 35 years hits "the legacy wall".

What would one lose when the "slot-machine" scared
one into some

    Switch = ...,
    Result = (fun Case(...) when ... -> ...;
                  Case(...) when ... -> ...
              end)(Switch),
?

~M

--

Normality is merely a question of quantity,
not of quality.

Normalität ist nur eine Frage von Quantität,
nicht von Qualität.





More information about the erlang-questions mailing list