diff options
| author | Anders Leino <aleino@nvidia.com> | 2025-02-11 02:42:08 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-10 16:42:08 -0800 |
| commit | 3c2d46aa1c8575dc046d7457793e77c7a4789093 (patch) | |
| tree | b333f6f799b975ca4e18fadd3cec0a144d8ec082 /docs/proposals/011-structured-binding.md | |
| parent | 133bd259c00984c6a01869f71951a7feb919463a (diff) | |
Remove the docs/proposals directory (#6313)
* Remove the docs/proposals directory
This directory will get added to the spec repository in the following PR:
https://github.com/shader-slang/spec/pull/6
This closes #6155.
* Remove entry from .github/CODEOWNERS file
* Redirect some proposal references
---------
Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'docs/proposals/011-structured-binding.md')
| -rw-r--r-- | docs/proposals/011-structured-binding.md | 47 |
1 files changed, 0 insertions, 47 deletions
diff --git a/docs/proposals/011-structured-binding.md b/docs/proposals/011-structured-binding.md deleted file mode 100644 index 59b671ee5..000000000 --- a/docs/proposals/011-structured-binding.md +++ /dev/null @@ -1,47 +0,0 @@ -SP #011: Structured Binding -================= - -Tuple types can reduce boilterplate code of defining auxiliary structs, but they can introduce readability issues because the elements are not named. -To mitigate this issue, we should support structured binding as a convenient way to access tuple elements with meaningful names. - -# Status - -Status: Proposal in review. - -Implementation: N/A - -# Proposed Approach - -Users should be able to use `let` syntax to assign a composite type to a binding structure: - -``` -let tuple = makeTuple(1.0f, 2, 3); -let [a, b, c] = tuple; -``` - -Where the `let [...]` statement is a syntactic sugar of: -``` -let a = tuple._0; -let b = tuple._1; -let c = tuple._2; -``` - -The right hand side of a structured binding can be a tuple, an array, or a struct type. -It is not an error if the composite value has more elements than the binding structure. - -Mutable bindings are not allowed. - -# Alternatives Considered - -We could have allowed mutable bindings in the syntax of: -``` -var [a,b,c] = ... -``` -That defines mutable variables a,b,c whose values are copied from the structure. -However, mutable bindings can lead to confusions when modifying `a` doesn't change the value -int the source composite object from the binding. To avoid this confusion, we simply disallow -it. - -Supporting mutation on the original composite object can be tricky as it involves reference types -that are not existent in the language. For simplicity we consider that to be out of scope of this -proposal.
\ No newline at end of file |
