[swift-evolution] Swift 3 Generics
Slava Pestov
spestov at apple.com
Fri Dec 18 00:17:57 CST 2015
> On Dec 15, 2015, at 8:45 PM, Douglas Gregor via swift-evolution <swift-evolution at swift.org> wrote:
>
>> - nesting (per Slava's email)
>> - ** Generic types nested inside generic functions
>> - ** Generic types nested inside generic types
>> - ** Generic functions nested inside generic functions which capture values or outer generic types
>
> I think Slava and I disagree on this one ;)
I think mostly we agree actually. :-) Your list of generics ABI tasks makes sense to me.
I don’t have any strong opinions about specific features going in now or later to be honest. I think in the long term we will likely end up implementing most of the features on Matthew's list, in one form or another. To keep things manageable we need to keep simplifying the conceptual model and paying off technical debt along the way.
So what I’d like to contribute to this effort is helping brainstorm what refactoring work needs to be done, and how to break down into manageable chunks since we can’t realistically fix everything. Also, in general I feel we haven’t nailed down the full conceptual model for the implementation of generics yet, but this is hard to quantify.
>
> I don't consider this critical for Swift 3. The compiler will greatly improve simply by making this work (because the dumb assumptions that block this feature likely trigger additional bugs), but we don't need to allow it for ABI stability.
I’m just happy now that nested generics don’t crash as much in Sema. It always bothered me when forgetting a ‘}’ could make the compiler crash just because you accidentally introduced nested generic context. :-)
> I suspect I'll remember other small things, but that's the "big" list... and it's size perhaps illustrates why we need to choose carefully to maintain focus.
Not ABI obviously, but what are your thoughts of adding a new ‘assoctype’ keyword instead of overloading ‘typealias’ in protocols? This has come up several times on this list and on Twitter. I’m quite like the idea.
Also, a frequent user request is self-conforming protocols. Personally I have mixed feelings about this — the implementation Joe and I came up with would require double-dispatching through a per-protocol witness table that opened existentials, which creates some conceptual difficulties which may or may not be possible to fix with some hacks, eg if T : P and T is bound to P, existential erasure of T to P would produce a double-wrapped existential P, which would create problems for casts among other things. I haven’t thought about if this impacts the ABI or not.
Slava
>
> - Doug
>
>
>> Thanks,
>> Matthew
>>
>>
>>
>>> On Dec 11, 2015, at 11:24 PM, Douglas Gregor <dgregor at apple.com <mailto:dgregor at apple.com>> wrote:
>>>
>>>
>>>> On Dec 10, 2015, at 3:45 PM, Matthew Johnson via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>>>>
>>>> One of the stated focus areas for Swift 3 is to complete the generics system.
>>>>
>>>> How far along is the design for the “complete” generics system?
>>>
>>> There’s a loose shared understanding of the pieces we need among the compiler and standard library developers that have been co-evolving the generics system, but it’s not written down in any single place.
>>>
>>>> Is there appetite among the core team to involve the community in evaluating planned features or submitting proposals to complement existing plans?
>>>
>>> Yes, absolutely. I feel like we (the core team) need to articulate our vision here—what we feel we need to accomplish (in features, in the standard library API, in the implementation) in Swift 3 vs. what we believe we can introduce later on, how the pieces all fit together, etc.—to help facilitate those discussions.
>>>
>>>> Also, is there any documentation other than https://github.com/apple/swift/blob/master/docs/Generics.rst <https://github.com/apple/swift/blob/master/docs/Generics.rst> describing in detail what the complete vision for the generics system is and what new features will be added in Swift 3 (as well as any generics features that have been decided against for Swift or version 3 specifically)?
>>>
>>> No, that document is the best overall documentation for the vision of the generics system, despite being mostly untouched for more than two years and lacking newer features (protocol extensions, anyone?).
>>>
>>> So, we need to write up a document describing our vision here. It’s going to take a little time, both because it’s a nontrivial task and because the likely principal authors are also engaged in other large Swift 3 tasks (e.g., https://github.com/apple/swift-evolution/blob/master/proposals/0005-objective-c-name-translation.md <https://github.com/apple/swift-evolution/blob/master/proposals/0005-objective-c-name-translation.md>)
>>>
>>> - Doug
>>>
>>>
>>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org <mailto:swift-evolution at swift.org>
> https://lists.swift.org/mailman/listinfo/swift-evolution <https://lists.swift.org/mailman/listinfo/swift-evolution>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151217/cf07de51/attachment.html>
More information about the swift-evolution
mailing list