-
Notifications
You must be signed in to change notification settings - Fork 23
Support sequence, array, and map destructuring declarations #37
Copy link
Copy link
Closed
Labels
FeatureA change that introduces a new featureA change that introduces a new featurePRG-hardCategorized as "hard" at the Prague f2f, 2024Categorized as "hard" at the Prague f2f, 2024PRG-optionalCategorized as "optional for 4.0" at the Prague f2f, 2024Categorized as "optional for 4.0" at the Prague f2f, 2024Propose for V4.0The WG should consider this item critical to 4.0The WG should consider this item critical to 4.0XPathAn issue related to XPathAn issue related to XPath
Metadata
Metadata
Assignees
Labels
FeatureA change that introduces a new featureA change that introduces a new featurePRG-hardCategorized as "hard" at the Prague f2f, 2024Categorized as "hard" at the Prague f2f, 2024PRG-optionalCategorized as "optional for 4.0" at the Prague f2f, 2024Categorized as "optional for 4.0" at the Prague f2f, 2024Propose for V4.0The WG should consider this item critical to 4.0The WG should consider this item critical to 4.0XPathAn issue related to XPathAn issue related to XPath
Given a function that returns a sequence, array, or map of a fixed length or structure, it would be useful to extract those values in a destructuring declaration like can be done in other languages (such as JavaScript, Kotlin, C++, and Python). For example:
These would be equivalent to:
It should be possible to define the type of a component and/or the whole construct:
For maps, it would also be useful to rename the components, such as:
It should also be possible to capture any left-over items in the sequence/array/map, for example:
A destructuring declaration should be usable anywhere a variable binding can be defined.
It should not be an error to use the same variable name twice. This supports conventions such as using
_for unused values. For example: