How long can I extend that “re-” pattern? 😀 But this post seems to be the last.
What you may be missing is that such a feature creates a new coupling of the names at the declaration site to the names at every (separately compiled) use site, meaning the consequences of alpha-renaming goes from zero to disaster. We can’t pull that kind of switch on people.
Actually there is an existing agreement that renaming of method parameters is without consequence. Specific transforms are called out in JLS as binary compatible.
I had already mentioned my concern about the strong coupling that named parameters introduce in the first revisited post. Even though the coupling is just a strong as when a custom class is used as a parameter, developers simply do not expected this coupling on named parameters. But the fact that the specification defines that renaming parameters names are to be without consequence, makes named parameters a dead end.
And also because something else has changed since 2013… EDI’s:
And that makes the price to pay for adding named parameters not worth it.
That said, it still was fun to let the idea run through one’s head. And likewise it also is fun to see if there is a way to make this work without renaming parameters… What about using the recently added record classes? Consider this a little creative piece of code (aka it will not compile):(more…)