Unnamed variables and match-all patterns

John Rose john.r.rose at oracle.com
Thu Sep 8 04:16:48 UTC 2022


> 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…


More information about the amber-spec-observers mailing list