New EEP draft: Pinning operator ^ in patterns

Ivan Uemlianin ivan@REDACTED
Fri Jan 15 23:04:16 CET 2021


You give data to show how little this new widget would be used in a 
fairly large codebase.

You imply that this new thing would improve "readability and 
maintainability".  Do you have any data to back up that claim?

This addition would be used so little, it has questionable benefits, the 
response to it has been almost unanimously against, ... surely the 
erlang maintainers have better things to do with their time.

This new bug would damage the language and pushing it through would 
damage the community.

Ivan


On 15/01/2021 12:34, Richard Carlsson wrote:
> There have been many strong reactions in this thread, so let me give 
> you some statistics to show how much this feature of using bound 
> variables is actually used in practice. I checked the entire OTP 
> codebase: there are just over 1300 modules, and in total about 595000 
> variable occurrences in patterns, of which only 3350 are already 
> bound.. That makes 0.56% of all variables in patterns - about once in 
> 200 to make it simple. On average, that's 2-3 usages per module - some 
> modules using it more and some not using it at all.
>
> I find it hard to see, then, why it should be a big issue to ask 
> programmers to annotate these few occurrences for readability and 
> maintainability. It's certainly not as big of a change as for example 
> when the warning for unused variables, unless prefixed with _, was 
> made the default.
>
> Imagine a world where Erlang had not allowed already-bound variables 
> in patterns (forcing you to use the idiom "X1 when X1 =:= X -> ...", 
> as in e.g. Haskell), and that someone now came with the suggestion 
> that to make things simpler, we could just implicitly match on the 
> value of X if X is already bound. The old me from my university days 
> would probably have said "that's really elegant, let's do it". But the 
> maintainability-and-readability me, with experience of very large code 
> bases, large numbers of developers, and many relative newcomers to the 
> language, would say "aw hell no". This is a cute feature, but it 
> carries a large cognitive cost and is not worth having compared to how 
> relatively little it is used. Being explicit about intention is much 
> more important.
>
>         /Richard
>
>
> Den tors 24 dec. 2020 kl 21:10 skrev Richard Carlsson 
> <carlsson.richard@REDACTED <mailto:carlsson.richard@REDACTED>>:
>
>     The ^ operator allows you to annotate already-bound pattern
>     variables as ^X, like in Elixir. This is less error prone when
>     code is being refactored and moved around so that variables
>     previously new in a pattern may become bound, or vice versa, and
>     makes it easier for the reader to see the intent of the code.
>
>     See also https://github.com/erlang/otp/pull/2951
>     <https://github.com/erlang/otp/pull/2951>
>
>     Ho ho ho,
>
>             /Richard & the good folks at WhatsApp
>

-- 
============================================================
Ivan A. Uemlianin PhD
Llaisdy

Ymchwil a Datblygu Technoleg Lleferydd
Speech Technology Research and Development

                     ivan@REDACTED
                         @llaisdy
                          llaisdy.wordpress.com
               github.com/llaisdy
                      www.linkedin.com/in/ivanuemlianin

                         festina lente
============================================================

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20210115/a920319c/attachment.htm>


More information about the erlang-questions mailing list