Alejandro Serrano.Mena
07/02/2025, 10:56 AMzt
07/09/2025, 2:21 PM{ val a, val b } = Pair(1, 2)
In my opinion it's more natural I think
Another thing what if the `val`/`var` could be lifted out the destructuring block if theyre all the same? Correct me if I'm wrong but immutable fields would be more common when destructuring. So it would be simpler to write for example
val { a, b } = Pair(0, 1)Alejandro Serrano.Mena
07/10/2025, 7:26 AM{ val x, it cannot distinguish whether a new block is starting, or a destructuring is startingAlejandro Serrano.Mena
07/10/2025, 7:27 AMval (a, b) syntax (or val [a, b]) we all know and loveAmejonah 1200
05/17/2026, 11:07 AMval { val x, val b } = ...
val { x, b } = ...
👀Amejonah 1200
05/17/2026, 11:09 AM() when we can go with val {}, which is familiar and repeatable in other contextsAlejandro Serrano.Mena
05/18/2026, 6:30 AM{ is a no-go because it's not parseableAmejonah 1200
06/05/2026, 9:52 AMval { text } = f()
f().let { val { text } -> }
fun f2(val { text }: Foo) = ...
But I agree that my overall proposal talks about pattern matching, however, this is due to convey a bigger picture. To make my proposal non-matching, any fallible constructs can be removed and the idenfier at <obj> as well.
---
Should I rewrite the proposal (separating patten deconstruction and matching) more clearly in KEEP format and post it in this channel?Amejonah 1200
06/05/2026, 9:54 AMAlejandro Serrano.Mena
06/05/2026, 9:54 AM( and not { are concious decisions by the team. The feature is already there for a few version, on its way to stabilization, and migration help has been implemented in IntelliJ -- so honestly I don't think this decision is going to be reversedAmejonah 1200
06/05/2026, 9:55 AMAmejonah 1200
06/05/2026, 9:56 AMAlejandro Serrano.Mena
06/05/2026, 9:58 AMdue to it being experimental, it can be changedIn general, this is true. Context-sensitive resolution or companion blocks/extensions have changed their design during the review process. In this case, though, those issues were already raised during the design (both within our team and in the KEEP review), considered, and a decision was already made on those particular issues. This is why this case is different, and I don't expect reversing those decisions unless a very big issue arises.
Amejonah 1200
06/05/2026, 9:59 AMAmejonah 1200
06/05/2026, 10:00 AMAlejandro Serrano.Mena
06/05/2026, 10:01 AMAmejonah 1200
06/05/2026, 10:03 AMAmejonah 1200
06/05/2026, 10:04 AM() still meant componentN and positional (no need to even deprecate + still would've been familiar), [] meant indexable (get) and {} would meant nominal.Amejonah 1200
06/05/2026, 10:17 AMAlejandro Serrano.Mena
06/05/2026, 10:58 AM( syntax to do name-based destructuring (which is the best default), and make position-based destructuring harder (because it doesn't work in the general case). It's not yet out, but I recommend watching Mikhail's talk at KotlinConf this year to get more background on this.