[swift-evolution] Proposal for generic protocols

David Hart david at hartbit.com
Thu Dec 3 16:39:55 CST 2015


I have been waiting a long time for something like this. I’m 100% behind this.

> On 03 Dec 2015, at 23:12, Tal Atlas <me at tal.by> wrote:
> 
> With the awesome expansion of protocol oriented programming that swift has allowed, the lack of generic protocols has felt noticeably lacking and painful in some cases. I made an in depth proposal here: https://github.com/tal/swift-evolution/blob/tal/generic-protocol-proposal/proposals/NNNN-add-generic-protocols.md <https://github.com/tal/swift-evolution/blob/tal/generic-protocol-proposal/proposals/NNNN-add-generic-protocols.md>
> 
> But the tl;dr is this:
> 
> protocol Validator<TypeToValidate> {
>   var value: TypeToValidate { get set }
>   var valueIfValid: TypeToValidate? { get }
> }
> 
> struct FooStringValidator: Validator<String> {
>   //... implementation
> }
> 
> let stringValidator: Validator<String>
> 
> Look forward to hearing some feedback.
>  _______________________________________________
> 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/20151203/54cf7352/attachment.html>


More information about the swift-evolution mailing list