linter/checker for single-threaded state via numbered variables?
Fernando Benavides
elbrujohalcon@REDACTED
Mon Jan 27 15:09:57 CET 2020
This looks like a great rule to add to Elvis
<https://github.com/inaka/elvis/>.
Would you mind writing an issue for it here
<https://github.com/inaka/elvis/issues>?
Or if you're brave enough, we also accept Pull Requests ;)
Cheers!
On Mon, Jan 27, 2020 at 2:22 PM Mikael Pettersson <mikpelinux@REDACTED>
wrote:
> Since Erlang doesn't allow you to rebind a variable in a scope where it's
> already bound (that becomes a match instead), there is a convention of
> using numbered variables to denote successive "generations" of some object
> or state that's intended to be used in a single-threaded or linear way.
> For example:
>
> foo(X0) ->
> X1 = update(X0),
> case predicate(X1) of
> true ->
> X2 = another_update(X1),
> persist(X2);
> false ->
> persist(X1)
> end.
>
> Here, whenever X(N+1) becomes bound, X(N) should become unused, and it
> should be an error if X(N) did not become unused. A variation is that the
> "final" value is the one without a number suffix.
>
> Is there any Erlang linter or style checker that can perform these types
> of checks?
>
--
<https://about.me/elbrujohalcon?promo=email_sig&utm_source=product&utm_medium=email_sig&utm_campaign=gmail_api&utm_content=thumb>
Brujo Benavides
about.me/elbrujohalcon
<https://about.me/elbrujohalcon?promo=email_sig&utm_source=product&utm_medium=email_sig&utm_campaign=gmail_api&utm_content=thumb>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20200127/4a8c1fea/attachment.htm>
More information about the erlang-questions
mailing list