<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
<br class="">
<div><br class="">
<blockquote type="cite" class="">
<div class="">On Sep 7, 2022, at 1:41 PM, Brian Goetz <<a href="mailto:brian.goetz@oracle.com" class="">brian.goetz@oracle.com</a>> wrote:</div>
<div class="">
<div class=""><font class=""><font class="">. . .<br class="">
<br class="">
<font face="monospace" size="4" class="">Where we stumble is on method parameters, because method parameter names serve two masters -- the implementation (as the declaration of a variable) and the API (as part of the specification of what the method does.) 
 Among other things, we like to document the semantics of method parameters in Javadoc with the `@param` tag, but doing so requires a name </font><br class="">
</font></font></div>
</div>
</blockquote>
<br class="">
</div>
<div>And a general language-design pattern is that if you discover a single language feature is serving two masters, consider splitting it into two features, one to serve each master (and then perhaps continue to allow the old feature, explaining it in terms
 of the new, more general features.</div>
<div><br class="">
</div>
<div>In this case, a single feature (method parameter name) provides both a name for the implementation and a name for the API. So, consider having a way to provide two names. Common Lisp has been doing this for its keyword parameters for almost four decades:</div>
<div><br class="">
</div>
<div>(defun foo (&key ((:color c) white) ((:angle a) 0))</div>
<div>   … c … a …)</div>
<div><br class="">
</div>
<div>(foo :color black :angle 45)</div>
<div><br class="">
</div>
<div>So the names :color and :angle are part of the API, and the names c and a are the variable names that are actually bound for use in the body.</div>
<div><br class="">
</div>
<div>When you write</div>
<div><br class="">
</div>
<div>(defun baz (&key (color white) (angle 0))</div>
<div>  … color … angle)</div>
<div><br class="">
</div>
<div>it is by definition an abbreviation for</div>
<div><br class="">
</div>
<div>
<div>(defun baz (&key ((:color color) white) ((:angle angle) 0))</div>
<div>  … color … angle)</div>
<div class=""><br class="">
</div>
<div class="">So you don’t have to write out two names in the common case where you actually do want them to be “the same”.</div>
<div class=""><br class="">
</div>
</div>
<div>————</div>
<div><br class="">
</div>
So in Java we could pick some crazy syntax to allow specifying two names for a method parameter, the API name and the implementation (bound variable) name:
<div class=""><br class="">
</div>
<div class="">int colorHack(int red=>r, int green=>g, int blue=>b, int fromIndex=>from, int toIndex=>to) {</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>// Here the names `r`, `g`, `b`, `from`, and `to` are in scope.</div>
<div class="">}</div>
<div class=""><br class="">
</div>
<div class="">and then if you really want to ignore a parameter:</div>
<div class=""><br class="">
</div>
<div class="">
<div class="">int colorBlindHack(int red=>_, int green=>_, int blue=>_, int fromIndex=>from, int toIndex=>to) {</div>
<div class=""><span class="Apple-tab-span" style="white-space: pre;"></span>// Here the names `from` and `to` are in scope.</div>
<div class="">}</div>
</div>
<div class=""><br class="">
</div>
<div class="">Not sure we want to go in that direction, but we should at least consider it.</div>
<div class=""><br class="">
</div>
<div class="">—Guy</div>
<div class=""><br class="">
</div>
</body>
</html>