[swift-evolution] [Review] SE-0023 API Design Guidelines
Thorsten Seitz
tseitz42 at icloud.com
Sun Jan 24 04:15:14 CST 2016
Yes, I think they are a lot like sum (or union) types. In Ceylon enums actually are modeled as union types (there is no specific enum syntax).
-Thorsten
> Am 23.01.2016 um 19:57 schrieb Trent Nadeau via swift-evolution <swift-evolution at swift.org>:
>
> While enum cases may not be types from a compiler perspective, I think they are from a user's level.
>
> Consider:
>
> enum MyError: ErrorType {
> case FileError(fileName: String)
> case SocketError(ipAddr: String, port: Int16)
> }
>
> From a compiler perspective, it's a tagged union (one type), but for a user this is a set of disjoint types that happen to share the same space and have exhaustiveness checking, etc. It's a much more efficient and convenient version of multiple structs or tuples.
>
> On Sat, Jan 23, 2016 at 1:49 PM, Joe Groff <jgroff at apple.com <mailto:jgroff at apple.com>> wrote:
>
> > On Jan 23, 2016, at 10:24 AM, Trent Nadeau <tanadeau at gmail.com <mailto:tanadeau at gmail.com>> wrote:
> >
> > I think it makes sense for enum cases to be UpperCamelCase as they can be thought of as scoped types (singleton types in the case of cases with no associated types).
>
> They aren't, though. I don't see much value in setting false expectations.
>
> -Joe
>
>
>
>
> --
> Trent Nadeau
> _______________________________________________
> 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/20160124/43a579e3/attachment.html>
More information about the swift-evolution
mailing list