Skip to content

Commit c97df33

Browse files
committed
SE-244: Include structural opaque types in future directions
1 parent 2b28cfb commit c97df33

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

proposals/0244-opaque-result-types.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,29 @@ The term "opaque" is also fairly heavily overloaded in the Swift implementation
616616

617617
## Future Directions
618618

619+
### Opaque types in structural position
620+
621+
This proposal only allows for the entire return type of a declaration to be
622+
made opaque. It would be reasonable to eventually generalize this to allow
623+
for opaque types to appear structurally, as part of an optional, array, or
624+
other generic type:
625+
626+
```
627+
func collection(or not: Bool) -> (some Collection)? {
628+
if not { return nil }
629+
return [1, 2, 3]
630+
}
631+
```
632+
633+
Furthermore, there could conceivably be multiple opaque parts of a compound
634+
return type:
635+
636+
```
637+
func twoCollections() -> (some Collection, some Collection) {
638+
return ([1, 2, 3], ["one": 1, "two": 2, "three": 3])
639+
}
640+
```
641+
619642
### `where` constraints on associated types of opaque types
620643

621644
This proposal does not yet provide a syntax for specifying constraints on

0 commit comments

Comments
 (0)