[swift-evolution] Swift 3 Generics

Slava Pestov spestov at apple.com
Thu Dec 10 22:35:09 CST 2015


> On Dec 10, 2015, at 4:14 PM, Austin Zheng via swift-evolution <swift-evolution at swift.org> wrote:
> 
> +1 to this. I would really like to see what is and isn't in scope for Swift 3's generics system. Among other things, it would help focus the community's proposals and ideas for the evolution of the type system. An example, people have expressed interest in HKTs, and perhaps a discussion can be opened on how Swift 3's type system can lay the foundation for further changes.
> 

Off the top of my head, the following are not currently supported and are requirements for any kind of ‘complete’ generics system:

- 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

All of these would be easier once we rip out PolymorphicFunctionType and GenericParamList in favor of consistently using GenericFunctionType and GenericSignature everywhere. This is what Sema’s “getType()” vs “getInterfaceType()” business on ValueDecls is all about. Once the old “contextual” types are gone, some tricky parallel code paths for building up the two representations of generic function signatures will be much simpler and more robust, and the missing functionality added easier. This is blocked on a number of architectural changes, for example SIL type lowering has to be able to associate a GenericTypeParamType with the GenericSignature that contains it, and right now it can’t really do that except for one distinguished GenericSignature, which forces us to use non-interface types when forming calls and such.

A large number of compiler_crashers are instances of the above three unsupported constructs which trip Sema bugs — even though we have diagnostics that catch most of these, the fact that the type checker doesn’t just stop after diagnosing once means that internal inconsistencies resulting an incomplete implementation of generics can trigger assertions down the road.

Slava

> Austin
> 
> On Thu, 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?  Is there appetite among the core team to involve the community in evaluating planned features or submitting proposals to complement existing plans?
> 
> 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)?
> 
> Thanks,
> Matthew
> 
> 
> _______________________________________________
> 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>
> 
> 
>  _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151210/2c67a81d/attachment.html>


More information about the swift-evolution mailing list