Cosmetic proposal: allow _underscore at the beginning of parameter names

In at least one other language (emacs lisp), the convention is that parameters prefixed with an underscore are ignored by the function. That is, the compiler won’t generate warnings about unused parameters for underscore-prefixed names, whereas for ordinary names it does. Elm has a limited version of this in the sense that you can use _ as a parameter name to indicate an unused binding, whose value cannot be referred to in the function, as an enforced feature of the language. (But there are no compiler warnings about named bindings that go unused, AFAIK).

Other languages (e.g. Python) use a convention that underscore-prefixed names (as members of a class for instance) are “internal” and should not be accessed by third-party code. But this is just an orthographic convention with no language support. (Because of elm’s design, privateness of names is not really an issue that arises for us.)

Based on other programming languages, there are several things that underscore-prefixed names could mean (including “nothing special”). I think it would be strange (to me personally, not to generalize to anyone else) to read code where underscores meant “function parameters”. That sounds like an informal and conventional version of something like Perl’s sigils, which I don’t like (and have never fully understood, again this is a very personal opinion).

I do agree that there are issues with the ergonomics of function parameters that shadow names in the module scope (e.g.) – but I don’t think there’s a clear answer yet.

1 Like