Name-based + new position-based destructuring #438
Replies: 8 comments 33 replies
-
One of the open design questions is what properties should be available through this syntax. There are three possible levels: 🚀 Only primary constructor properties 1️⃣, To direct discussion, I would love to gather feedback on this specific point in this thread. Please use emojis 🚀/🎉/❤️ (edit: GitHub does not allow generic emoji responses) if you just want to state "I prefer this option" without any additional reasoning. |
Beta Was this translation helpful? Give feedback.
-
About further extensions:
I think allowing assignments without mixing with declarations is already useful and covers a common case: [a, b] = b to a Mixing can be added if the use-cases are found. |
Beta Was this translation helpful? Give feedback.
-
I see a problem in the current design. From the declaration below it is not fully comprehensible, which of the names is a property of a class and which is a variable. (val name1 = name2, ...) = ... One may say that the one near f(a = b) The first one is proposed by the declaration owner and the SECOND one is OUR argument. In the proposed feature the FIRST one is OUR name. Do you consider something like: (val name1 = .name2, ...) = ... (val name1 = declaration.name2, ...) = ... (val name1 = decl.name2, ...) = ... The following was also suggested in the comments: (val name1 = _.name2, ...) = ... Another problem is that if you have a variable with the declaration name above, it is not obvios that you reference not it: val name2 = "#"
(val name1 = name2, ...) = ... // name2 here is not from above So, the |
Beta Was this translation helpful? Give feedback.
-
See:
It would be nice to stop using |
Beta Was this translation helpful? Give feedback.
-
Am I correct that with the long-term syntax (post-migration), you would not be required to specify any |
Beta Was this translation helpful? Give feedback.
-
For the migration plan, it would be very nice to have the ability to start with Phase 3 for new projects and projects that have been manually migrated. E.g. with an experimental compiler arg. |
Beta Was this translation helpful? Give feedback.
-
I want to push back a tiny bit on the |
Beta Was this translation helpful? Give feedback.
-
A question about what happens as the number of deconstructed properties goes down to 1, especially after phase 3: would you be able to write On the one hand, it seems silly to allow this when On the other hand, disallowing it would be an arbitrary restriction:
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
This is an issue to discuss name-based destructuring and new syntax for position-based destructuring. The current full text of the proposal can be found here.
We propose a new form of destructuring based on names instead of positions. In addition, we propose new syntax for position-based destructuring.
Beta Was this translation helpful? Give feedback.
All reactions