You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: proposals/NNNN-allow-additional-args-to-dynamicmemberlookup-subscripts.md
+47-41Lines changed: 47 additions & 41 deletions
Original file line number
Diff line number
Diff line change
@@ -211,9 +211,9 @@ let _: String = C().member // (5); no ambiguity
211
211
let _: String?=C().member// (6) preferred over (5); ⚠️ previously (5) ⚠️
212
212
```
213
213
214
-
This last case is the only source of behavior change: (6) was previously not considered a valid candidate, but has a return type more specific than (5**, and is now picked at a callsite.
214
+
This last case is the only source of behavior change: (6) was previously not considered a valid candidate, but has a return type more specific than (5), and is now picked at a callsite.
215
215
216
-
**In practice, it is expected that this situation is exceedingly rare.**
216
+
In practice, it is expected that this situation is exceedingly rare.
217
217
218
218
## ABI compatibility
219
219
@@ -225,45 +225,51 @@ The changes in this proposal require the adoption of a new version of the Swift
225
225
226
226
## Alternatives considered
227
227
228
-
The main alternative to this proposal is to not implement it. This is possible to work around using explicit methods such as `get()` and `set(_:)`:
The main alternative to this proposal is to not implement it, as:
229
+
1. It was noted in [the pitch thread](https://forums.swift.org/t/pitch-allow-additional-arguments-to-dynamicmemberlookup-subscripts/79558) that allowing additional arguments to dynamic member lookup widens the gap in capabilities between dynamic members and regular members — dynamic members would be able to
230
+
a. Have caller side effects (i.e., have access to `#function`, `#file`, `#line`, etc.),
231
+
b. Constrain themselves via generics, and
232
+
c. Apply isolation to themselves via `#isolation`
233
+
where regular members cannot. However, (a) and (c) are not considered an imbalance in functionality but instead are the raison d'être of this proposal. (b) is also already possible today as dynamic member subscripts can be constrained via generics (and this is often used with keypath-based lookup).
234
+
2. This is possible to work around using explicit methods such as `get()` and `set(_:)`:
0 commit comments