Amber features 2026
Brian Goetz
brian.goetz at oracle.com
Wed Jan 14 20:05:04 UTC 2026
> But I'm still ambivalent about that feature, for me, it looks like we are missing the big picture.
>
>
> Every time i've talked about this feature in JUGs, one of the questions was why do we need to indicate the type given that the compiler knows it.
Except that this is not big picture; it's more like code-golf.
Yes, the part of people's brains that, when shown a new feature, they
will try to squeeze out tokens that they do not see as essential, works
in permanent overdrive, so OF COURSE people will ask this. But this is
surface, not substance; the substance is that "exhaustive pattern" is a
thing, and it behaves very very similiarly to existing rules about
assignment.
There are future ideas in the pipeline that might be layered on and
reduce the ceremony of this and other things, but we're going to leave
that for another day.
> I wonder if the general question hidden behind is why is it a pattern assignment and not a de-structuration like in other languages.
Because Java does not have destructuring, because it does not have
structural types. It has records (nominal types) and record patterns
(and eventually carriers and deconstruction patterns for them), but
patterns are a step removed from destructuring.
> Or maybe, this feature should be named pattern declaration and not pattern assignment ?
The key aspect here is that we have a pattern that is known to be
exhaustive, from which we want to extract (assign) multiple bindings
unconditionally. Currently, such a pattern would have to use a
conditional construct, which (a) requires you use conditionality to deal
with something unconditional, and (b) prevents the compiler from doing
better type checking. When a pattern is exhaustive, it behaves _just
like local variable declaration with initialization_, which operates by
assignment. You can think of "pattern assignment" as a shorthand for
for that.
> For me, this feature is about de-structuring assignment but by seeing through the keyhole of patterns, i'm fearing we are missing the big picture here.
Please show me what you think is the big picture, because these examples
all look like code golf to me so far.
More information about the amber-spec-experts
mailing list