New EEP draft: Pinning operator ^ in patterns

Richard Carlsson carlsson.richard@REDACTED
Thu Jan 21 22:16:21 CET 2021


Den tors 21 jan. 2021 kl 21:29 skrev Sean Hinde <sean.hinde@REDACTED>:

> Beginners writing such large functions they fall into the trap of variable
> re-use from far above the match would receive the wrong lesson though -
> they should take this as an indication to make their functions smaller
> rather than be encouraged to just make big functions littered with carets.
>

If you look at those diffs I posted, it only takes 10-20 lines and a bunch
of complicated tuples with many variables before it gets quite hard to see
what's what. And there are many many functions larger than that in typical
Erlang code out there. Even if you encourage people to keep their functions
short, they will in any case need to dive into existing and unfamiliar code
and understand it; maybe onboarding on a new job, or just switching teams.
The code won't be littered with carets; there won't be more uses of already
bound variables than today, i.e. a couple of times per module, on average.
But they're not hidden logic bombs anymore.

The change of culture resulting from this change could reduce the overall
> quality of Erlang code.
>

My bet is that the reverse will happen - people will be more aware of how
bindings flow between producers and consumers, and will be less fearful of
making changes to clean up confusing code.

        /Richard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20210121/fa82dbc9/attachment-0001.htm>


More information about the erlang-questions mailing list