Unnamed variables and match-all patterns

Guy Steele guy.steele at oracle.com
Thu Sep 8 15:13:28 UTC 2022



> On Sep 8, 2022, at 12:16 AM, John Rose <john.r.rose at oracle.com> wrote:
> 
>> Aligning with the need for a double declaration, we could say that the `expr` part is the formal and external name of the parameter, and the `s` part is the local and internal name of the binding.  So:
>> 
>> int colorBlindHack(let int _ = red, let int _ = green, let int b = blue, …) …
>> 
>> Huh.  Looks too close to optional arguments for comfort.  And how would you combine it with optional arguments?
> 
> P.S.  (That is, Painting Shed.)  If we allowed Java the label-like syntax adopted by some languages for externally named keyword arguments it might look like this:
> 
> int colorBlindHack(red: int _, green: int _, blue: int, …)
> 
> The last argument keyworded as “blue” is bound to the name “blue” in the absence of other indication; the other choices being `blue: int _` for ignored argument and `blue: int b` for a different local name.
> 
> int colorHack(red: int, green: int, blue: int, …)   //keyword arguments
> 
> (The “L: FOO” syntax is already a thing in Java, see?)
> 
> So many bikesheds, so little time…

Wowww—this is one of the bikiest sheds I have seen in a long time. I am very impressed. Completely consistent to those who know the history, therefore very appealing! But also, alas, with the promise of totally confusing newcomers as to whether Java parameter declaration syntax is C-like or Pascal-like. :-)

—Guy



More information about the amber-spec-experts mailing list