[Erlang Forums] [Erlang/OTP Proposals/Proposals: RFC] Re-visiting EEP-0055

Attila Rajmund Nohl attila.r.nohl@REDACTED
Wed Apr 27 21:11:08 CEST 2022


Fred Dushin <fred@REDACTED> ezt írta (időpont: 2022. ápr. 27., Sze, 15:14):
>
[...]
> But as noted later in the EEP, this can be written as
>
> f(X, Y) ->
>     F = fun ({a, Z}) when Z =:= Y  -> {ok, Y};
>             (_) -> error
>         end,
>     F(X).
[...]
> And not to be too critical, but I am having a hard time understanding parts of the Rationale section.  The author(s) suggest(s) that in current Erlang temporary variables are needed to achieve the same as the proposed glyph, but then provide an example that uses a guard (as above) but doesn't use a temporary variable, after all (?)

Z is the temporary variable in the above example.

> I am not sure what the problem is with temporary variables.  The compiler has registers at its disposal, so I don't think it's a performance argument, but more an issue of readability, which again, I think is a purely aesthetic question, and has no bearing on the features of the language, per se.  In other words, the proposal is not suggesting anything that cannot already be achieved in current Erlang, with effectively the same compiled BEAM ASM.

Naming is hard, and if you have to come up with two meaningful
variable names instead of one, it's even harder. This leads to code
like this:

     F = fun ({a, TmpMeaningfulName}) when TmpMeaningfulName =:=
MeaningfulName  -> {ok, MeaningfulName};

The current solution in the language easily leads to too long lines or
overly verbose code.


More information about the erlang-questions mailing list