<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jun 22, 2016, at 9:11 AM, plx via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Jun 22, 2016, at 8:28 AM, T.J. Usiyan &lt;<a href="mailto:griotspeak@gmail.com" class="">griotspeak@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="">plx: wouldn't the same overload resolution strategy be appropriate here? "most specific choice, otherwise diagnostic”</div></div></div></blockquote><div class=""><br class=""></div><div class="">I’d assume it’d be good enough for most cases, certainly; I’d love to turn out to be needlessly scaremongering here, too.</div><div class=""><br class=""></div><div class="">But (hopefully unintentionally!) it seems like you could easily wind up with scenarios like this:</div><div class=""><br class=""></div><div class=""><div class="">&nbsp; // from proposal:</div><div class="">&nbsp; public subscript&lt;T&gt;(key: Key) throws -&gt; T {</div><div class="">&nbsp; &nbsp; guard let value = self[key] else { throw ... }</div><div class="">&nbsp; &nbsp; guard let ofType = value as? T else { throw ... }</div><div class="">&nbsp; &nbsp; return ofType</div><div class="">&nbsp; }</div><div class=""><br class=""></div><div class="">&nbsp; // an annoying addition:</div><div class="">&nbsp; public subscript&lt;T:RawRepresentable&gt;(key: Key) throws -&gt; T {</div><div class="">&nbsp; &nbsp; guard let v = self[key] else { throw ... }</div><div class="">&nbsp; &nbsp; guard let rawValue = v as? T.RawValue else { throw ... }</div><div class="">&nbsp; &nbsp; guard let converted = T(rawValue: rawValue) else { throw ... }</div><div class="">&nbsp; &nbsp; return converted</div><div class="">&nbsp; }</div><div class=""><br class=""></div><div class="">&nbsp; // assume `Foo:RawRepresentable`:</div><div class="">&nbsp; let foo: Foo = json["foo"]</div><div class=""><br class=""></div><div class="">…and similar, where I’d assume the `T:RawRepresentable` would “win”, but I’m not sure *how* you could force use of the *other* subscript in the above.</div><div class=""><br class=""></div><div class="">This isn’t really a new problem, but it seems likelier to be encountered if generic subscripts become allowed, due to all subscripts having the same “name”.</div></div></div></div></div></blockquote><div><br class=""></div><div>This isn’t exactly true. &nbsp;External argument labels are considered part of the “name” in Swift. &nbsp;Subscripts parameters don’t get external labels automatically like other functions / methods do, but you can still add one if you *want* the ability to disambiguate. &nbsp;</div><div><br class=""></div><div>Of course this won’t help if you require the ability to use both subscripts without a label but is worth noting. &nbsp;It is also worth noting that this behavior is no different from that of any other function or method - if the name (including external argument labels) matches the most specific overload will always be selected.</div><div><br class=""></div><div>One way to make your example work properly when `T` is `RawRepresentable` and the dictionary actually contains an instance of `T` is to add an extra check for that case:</div><div><br class=""></div><div>&nbsp; public subscript&lt;T:RawRepresentable&gt;(key: Key) throws -&gt; T {<br class="">&nbsp; &nbsp; guard let v = self[key] else { throw … }</div><div><br class=""></div><div>&nbsp; &nbsp; // extra check here in case the value is *already* T and therefore does not require conversion.</div><div>&nbsp; &nbsp; if let value = v as? T { return value }</div><div><br class="">&nbsp; &nbsp; guard let rawValue = v as? T.RawValue else { throw ... }<br class="">&nbsp; &nbsp; guard let converted = T(rawValue: rawValue) else { throw ... }<br class="">&nbsp; &nbsp; return converted<br class="">&nbsp; }</div><div><br class=""></div><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><div class=""><div class=""><br class=""></div><div class="">But again I’d like to be wrong about the issue (or at least the severity).</div><div class=""><br class=""></div></div><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><br class=""></div><div class="">separately:</div>Are there any subscripts in the standard library that would be throwing/generic but can't be?<div class=""><br class=""></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Wed, Jun 22, 2016 at 9:13 AM, plx via swift-evolution <span dir="ltr" class="">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt;</span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class="">Prefacing the below with a “I am well-aware this proposal likely won’t make it into Swift 3”:</div><div class=""><br class=""></div><div class="">A feature like this would be nice to use, but before I could get behind any proposal along these lines it I’d want to see it include an explicit strategy for disambiguation.</div><div class=""><br class=""></div><div class="">EG: in your example, your generic subscript uses `self[key]`, and presumably expects that to use the “original” subscript…and not the generic subscript being defined.</div><div class=""><br class=""></div><div class="">I think that’s reasonable in that specific case, but it doesn’t seem unreasonable to anticipate this proposal introducing ambiguities that would need explicit disambiguation…and for which explicit type annotation may not always be adequate to resolve (I could be wrong here, though).&nbsp;</div><div class=""><br class=""></div><div class="">This would need addressing (either showing they won’t be an issue, or providing a reliable disambiguation mechanism).</div><div class=""><br class=""></div><div class="">Relatedly, in-re: “rethrows”: if the syntax supported it, this kind of thing would be another way of tackling the "JSON problem":</div><div class=""><br class=""></div><div class="">&nbsp; subscript&lt;T&gt;(key: Key, transform: (Value) throws -&gt; T) rethrows -&gt; T {</div><div class="">&nbsp; &nbsp; guard let value = self[key] else { throw JSON.MissingKey(…) }</div><div class="">&nbsp; &nbsp; return try transform(value)</div><div class="">&nbsp; }</div><div class=""><br class=""></div><div class="">…so that e.g. you can write typical parsing-code as</div><div class=""><br class=""></div><div class="">&nbsp; let asUserID = UserID.init(untrustedString:) // &lt;- assume this is a "throwing constructor"</div><div class="">&nbsp; let sender = try json[“sender”,asUserID]&nbsp;</div><div class="">&nbsp; let recipient = try json[“recipient”,asUserID]</div><div class=""><br class=""></div><div class="">…(modulo any syntax errors, etc.), which would benefit from a `rethrows` declaration.</div><div class=""><br class=""></div><div class="">That’s my 2c; thankfully (IMHO) there’s clearly a lot of time for this proposal to simmer.</div><div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><div class=""><div class="h5"><div class="">On Jun 20, 2016, at 1:10 PM, Robert Widmann via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class=""></div></div><div class=""><div class=""><div class="h5"><div style="word-wrap:break-word" class="">Good morning all.&nbsp; Attached is the proposal Harlan Haskins and I will be submitting shortly about adding generic and `throw`ing subscript declarations to the language. &nbsp;<div class=""><br class=""></div><div class="">Cheers,</div><div class=""><br class=""></div><div class="">~Robert Widmann<br class=""><div class=""><br class=""></div><div class=""><h1 style="font-size:2.25em;margin-right:0px;margin-bottom:16px;margin-left:0px;line-height:1.2;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';margin-top:0px!important" class="">Generic and Throwing Subscripts</h1><ul style="padding-left:2em;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:14px" class=""><li class="">Proposal:&nbsp;<a href="https://github.com/apple/swift-evolution/blob/master/proposals/NNNN-name.md" style="color:rgb(64,120,192);text-decoration:none" target="_blank" class="">SE-NNNN</a></li><li class="">Author(s):&nbsp;<a href="https://github.com/harlanhaskins" style="color:rgb(64,120,192);text-decoration:none" target="_blank" class="">Harlan Haskins</a>&nbsp;and&nbsp;<a href="https://github.com/codafi" style="color:rgb(64,120,192);text-decoration:none" target="_blank" class="">Robert Widmann</a></li><li class="">Status:&nbsp;<span class=""><a href="https://github.com/typelift/SwiftCheck/pull/168#rationale" style="color:rgb(64,120,192);text-decoration:none" target="_blank" class="">Awaiting review</a></span></li><li class="">Review manager: TBD</li></ul><h2 style="margin-top:1em;margin-bottom:16px;line-height:1.225;font-size:1.75em;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol'" class="">Introduction</h2><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:14px" class="">Currently, subscripts cannot be declared&nbsp;<code style="font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:11.899999618530273px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="">[re]throws</code>&nbsp;and cannot declare new generic parameters.<br class="">There isn't a clear reason why they aren't as capable as full-fledged functions, so we propose<br class="">adding generic constraints and throwing semantics to subscripts.</p><h2 style="margin-top:1em;margin-bottom:16px;line-height:1.225;font-size:1.75em;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol'" class="">Motivation</h2><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:14px" class="">On the throwing side, currently there are two ways to express a failing subscript:</p><ul style="padding-left:2em;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:14px" class=""><li class="">Return an&nbsp;<code style="font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:11.899999618530273px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="">Optional</code>, failing with&nbsp;<code style="font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:11.899999618530273px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="">nil</code>.</li><li class="">Call&nbsp;<code style="font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:11.899999618530273px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="">fatalError(_:)</code>&nbsp;on failure.</li></ul><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:14px" class="">Both of these throw out useful information about the cause of the underlying error that using Swift's error handling mechanism can otherwise provide.</p><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:14px" class="">As for generics, to take an example, it has become a common pattern among JSON decoding DSL libraries to express a throwing generic extension on&nbsp;<code style="font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:11.899999618530273px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="">Dictionary</code>&nbsp;like so</p><div style="margin-bottom:16px;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:14px;overflow:visible!important" class=""><pre style="font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:11.899999618530273px;margin-top:0px;margin-bottom:0px;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-break:normal" class=""><span style="color:rgb(167,29,93)" class="">extension</span> <span style="color:rgb(0,134,179)" class="">Dictionary</span> {
    <span style="color:rgb(167,29,93)" class="">public</span> <span style="color:rgb(167,29,93)" class="">func</span> <span style="color:rgb(121,93,163)" class="">parse</span>&lt;T&gt;(key: Key) throws <span style="color:rgb(167,29,93)" class="">-&gt;</span> T {
        <span style="color:rgb(167,29,93)" class="">guard</span> <span style="color:rgb(167,29,93)" class="">let</span> value <span style="color:rgb(167,29,93)" class="">=</span> <span style="color:rgb(167,29,93)" class="">self</span>[key] <span style="color:rgb(167,29,93)" class="">else</span> {
            <span style="color:rgb(167,29,93)" class="">throw</span> JSONError<span style="color:rgb(167,29,93)" class="">.</span>MissingKey(<span style="color:rgb(24,54,145)" class=""><span class="">"</span><span class="">\(</span><span style="color:rgb(51,51,51)" class="">key</span><span class="">)</span><span class="">"</span></span>)
        }
        <span style="color:rgb(167,29,93)" class="">guard</span> <span style="color:rgb(167,29,93)" class="">let</span> ofType <span style="color:rgb(167,29,93)" class="">=</span> value <span style="color:rgb(167,29,93)" class="">as?</span> T <span style="color:rgb(167,29,93)" class="">else</span> {
            <span style="color:rgb(167,29,93)" class="">throw</span> JSONError<span style="color:rgb(167,29,93)" class="">.</span>InvalidKey(key: <span style="color:rgb(24,54,145)" class=""><span class="">"</span><span class="">\(</span><span style="color:rgb(51,51,51)" class="">key</span><span class="">)</span><span class="">"</span></span>, expectedType: T<span style="color:rgb(167,29,93)" class="">.</span><span style="color:rgb(167,29,93)" class="">self</span>, foundType: value<span style="color:rgb(167,29,93)" class="">.</span><span style="color:rgb(167,29,93)" class="">dynamicType</span>)
        }
        <span style="color:rgb(167,29,93)" class="">return</span> ofType
    }
}

<span style="color:rgb(167,29,93)" class="">public</span> <span style="color:rgb(167,29,93)" class="">enum</span> JSONError: <span style="color:rgb(0,134,179)" class="">ErrorType</span>, <span style="color:rgb(0,134,179)" class="">CustomStringConvertible</span> {
    <span style="color:rgb(167,29,93)" class="">case</span> InvalidKey(key: <span style="color:rgb(0,134,179)" class="">String</span>, expectedType: <span style="color:rgb(0,134,179)" class="">Any</span><span style="color:rgb(167,29,93)" class="">.</span><span style="color:rgb(167,29,93)" class="">Type</span>, foundType: <span style="color:rgb(0,134,179)" class="">Any</span><span style="color:rgb(167,29,93)" class="">.</span><span style="color:rgb(167,29,93)" class="">Type</span>)
    <span style="color:rgb(167,29,93)" class="">case</span> MissingKey(<span style="color:rgb(0,134,179)" class="">String</span>)
    <span style="color:rgb(167,29,93)" class="">public</span> <span style="color:rgb(167,29,93)" class="">var</span> description: <span style="color:rgb(0,134,179)" class="">String</span> {
        <span style="color:rgb(167,29,93)" class="">switch</span> <span style="color:rgb(167,29,93)" class="">self</span> {
        <span style="color:rgb(167,29,93)" class="">case</span> <span style="color:rgb(167,29,93)" class="">.</span>InvalidKey(<span style="color:rgb(167,29,93)" class="">let</span> key, <span style="color:rgb(167,29,93)" class="">let</span> expected, <span style="color:rgb(167,29,93)" class="">let</span> found):
            <span style="color:rgb(167,29,93)" class="">return</span> <span style="color:rgb(24,54,145)" class=""><span class="">"</span>Invalid key <span class="">\"</span><span class="">\(</span><span style="color:rgb(51,51,51)" class="">key</span><span class="">)</span><span class="">\"</span>. Expected value of type <span class="">\"</span><span class="">\(</span><span style="color:rgb(51,51,51)" class="">expected</span><span class="">)</span><span class="">\"</span>, found <span class="">\"</span><span class="">\(</span><span style="color:rgb(51,51,51)" class="">found</span><span class="">)</span><span class="">\"</span>.<span class="">"</span></span>
        <span style="color:rgb(167,29,93)" class="">case</span> <span style="color:rgb(167,29,93)" class="">.</span>MissingKey(<span style="color:rgb(167,29,93)" class="">let</span> key):
            <span style="color:rgb(167,29,93)" class="">return</span> <span style="color:rgb(24,54,145)" class=""><span class="">"</span>Key <span class="">\(</span><span style="color:rgb(51,51,51)" class="">key</span><span class="">)</span> not found.<span class="">"</span></span>
        }
    }
}</pre></div><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:14px" class="">Given this, one can decode JSON with the full support of native type inference and exception handling. But when working with the DSL, one would expect to be able to express this as a subscript on&nbsp;<code style="font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:11.899999618530273px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="">Dictionary</code>, allowing the following:</p><div style="margin-bottom:16px;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:14px;overflow:visible!important" class=""><pre style="font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:11.899999618530273px;margin-top:0px;margin-bottom:0px;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-break:normal" class=""><span style="color:rgb(150,152,150)" class="">//...</span>

<span style="color:rgb(167,29,93)" class="">extension</span> <span style="color:rgb(0,134,179)" class="">Dictionary</span> {
    <span style="color:rgb(167,29,93)" class="">public</span> <span style="color:rgb(167,29,93)" class="">subscript</span><span style="color:rgb(167,29,93)" class="">&lt;</span>T<span style="color:rgb(167,29,93)" class="">&gt;</span>(key: Key) <span style="color:rgb(167,29,93)" class="">throws</span> <span style="color:rgb(167,29,93)" class="">-&gt;</span> T {
        <span style="color:rgb(167,29,93)" class="">guard</span> <span style="color:rgb(167,29,93)" class="">let</span> value <span style="color:rgb(167,29,93)" class="">=</span> <span style="color:rgb(167,29,93)" class="">self</span>[key] <span style="color:rgb(167,29,93)" class="">else</span> {
            <span style="color:rgb(167,29,93)" class="">throw</span> JSONError<span style="color:rgb(167,29,93)" class="">.</span>MissingKey(<span style="color:rgb(24,54,145)" class=""><span class="">"</span><span class="">\(</span><span style="color:rgb(51,51,51)" class="">key</span><span class="">)</span><span class="">"</span></span>)
        }
        <span style="color:rgb(167,29,93)" class="">guard</span> <span style="color:rgb(167,29,93)" class="">let</span> ofType <span style="color:rgb(167,29,93)" class="">=</span> value <span style="color:rgb(167,29,93)" class="">as?</span> T <span style="color:rgb(167,29,93)" class="">else</span> {
            <span style="color:rgb(167,29,93)" class="">throw</span> JSONError<span style="color:rgb(167,29,93)" class="">.</span>InvalidKey(key: <span style="color:rgb(24,54,145)" class=""><span class="">"</span><span class="">\(</span><span style="color:rgb(51,51,51)" class="">key</span><span class="">)</span><span class="">"</span></span>, expectedType: T<span style="color:rgb(167,29,93)" class="">.</span><span style="color:rgb(167,29,93)" class="">self</span>, foundType: value<span style="color:rgb(167,29,93)" class="">.</span><span style="color:rgb(167,29,93)" class="">dynamicType</span>)
        }
        <span style="color:rgb(167,29,93)" class="">return</span> ofType
    }
}</pre></div><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:14px" class="">We believe this is an even more natural way to write these kinds of libraries in Swift and that bringing subscript member declarations up to par with functions is a useful addition to the language as a whole.</p><h2 style="margin-top:1em;margin-bottom:16px;line-height:1.225;font-size:1.75em;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol'" class="">Proposed solution</h2><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:14px" class="">Add the ability to introduce new generic parameters and mark&nbsp;<code style="font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:11.899999618530273px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="">throws</code>&nbsp;and <span style="font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:11.899999618530273px;background-color:rgba(0,0,0,0.0392157)" class="">rethrows&nbsp;</span>on subscript members.</p><h2 style="margin-top:1em;margin-bottom:16px;line-height:1.225;font-size:1.75em;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol'" class="">Detailed design</h2><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:14px" class="">This change will modify and add the following productions in the Swift grammar</p><div style="margin-bottom:16px;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:14px;overflow:visible!important" class=""><pre style="font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:11.899999618530273px;margin-top:0px;margin-bottom:0px;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-break:normal" class="">GRAMMAR OF A SUBSCRIPT DECLARATION

subscript-declaration → subscript-head subscript-result code-block
subscript-declaration → subscript-head subscript-result getter-setter-block
subscript-declaration → subscript-head subscript-result getter-setter-keyword-block
<span style="background-color:rgb(255,236,236);color:rgb(189,44,0)" class="">-subscript-head → attributes(opt) declaration-modifiers(opt) subscript parameter-clause</span>
<span style="background-color:rgb(234,255,234);color:rgb(85,165,50)" class="">+subscript-head → attributes(opt) declaration-modifiers(opt) generic-parameter-clause(opt) subscript parameter-clause</span>
<span style="background-color:rgb(234,255,234);color:rgb(85,165,50)" class="">+subscript-result → -&gt; attributes(opt) throws(opt) type</span>
<span style="background-color:rgb(234,255,234);color:rgb(85,165,50)" class="">+subscript-result → -&gt; attributes(opt) rethrows(opt) type</span></pre></div><hr style="min-height:4px;overflow:hidden;margin:16px 0px;background-color:rgb(231,231,231);border:0px none;padding:0px;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:14px" class=""><h1 style="font-size:2.25em;margin:1em 0px 16px;line-height:1.2;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol'" class="">Rationale</h1><div style="margin-top:0px;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:14px;margin-bottom:0px!important" class="">On [Date], the core team decided to&nbsp;<span class="">(TBD)</span>&nbsp;this proposal.<br class="">When the core team makes a decision regarding this proposal,<br class="">their rationale for the decision will be written here.</div></div></div></div></div></div><span class="">_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></span></div></blockquote></div><br class=""></div><br class="">_______________________________________________<br class="">
swift-evolution mailing list<br class="">
<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="">
<br class=""></blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></body></html>