Re: [Erlang Forums] [Erlang/OTP Proposals/Proposals: RFC] Re-visiting EEP-0055
Attila Rajmund Nohl <[email protected]> Wed, 27 Apr 2022 21:11:08 +0200
| Newsgroups | gmane.comp.lang.erlang.general |
|---|---|
| Message-ID | <CAFkcMa-oFkew5Ugk0X9yX+EyJVq4mt+HzPjjeLfVKP9mMvHmNQ@mail.gmail.com> |
Fred Dushin <[email protected]> ezt =C3=ADrta (id=C5=91pont: 2022. =C3=A1pr. = 27., Sze, 15:14): > [...] > But as noted later in the EEP, this can be written as > > f(X, Y) -> > F =3D fun ({a, Z}) when Z =3D:=3D Y -> {ok, Y}; > (_) -> error > end, > F(X). [...] > And not to be too critical, but I am having a hard time understanding par= ts of the Rationale section. The author(s) suggest(s) that in current Erla= ng 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 argumen= t, but more an issue of readability, which again, I think is a purely aesth= etic question, and has no bearing on the features of the language, per se. = In other words, the proposal is not suggesting anything that cannot alread= y be achieved in current Erlang, with effectively the same compiled BEAM AS= M. 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 =3D fun ({a, TmpMeaningfulName}) when TmpMeaningfulName =3D:=3D MeaningfulName -> {ok, MeaningfulName}; The current solution in the language easily leads to too long lines or overly verbose code.