[swift-evolution] [Pre-pitch] Allowing enums inside protocols?

Akshay Hegde akshay_hegde at me.com
Sat Jul 8 20:10:53 CDT 2017


Wouldn’t the following work just as well for providing a namespace?

struct Foozle {
    enum Errors: Error {
        case malformedFoozle
        case tooManyFoozles
    }
}

~Akshay

> On Jul 8, 2017, at 17:24, Jonathan Hull via swift-evolution <swift-evolution at swift.org> wrote:
> 
> I *really* want this as well.
> 
> I think there was a serious proposal to do this early in Swift 4.  Not sure why it stalled, but I seem to remember it being technically possible.
> 
> Thanks,
> Jon
> 
>> On Jul 8, 2017, at 4:21 PM, William Shipley via swift-evolution <swift-evolution at swift.org> wrote:
>> 
>> Does anyone know if there's some good tech reason to not allow, like:
>> 
>> protocol Foozle {
>> 	enum Errors: Error {
>> 		case malformedFoozle
>> 		case tooManyFoozles
>> 	}
>> }
>> 
>> Like, to me all this is doing is giving “Errors” a nice namespace, but the compiler might have other thoughts.
>> 
>> -W
>> _______________________________________________
>> swift-evolution mailing list
>> swift-evolution at swift.org
>> 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/20170708/5fcd421c/attachment-0001.html>


More information about the swift-evolution mailing list