[swift-evolution] [Review] SE-0023 API Design Guidelines

Trent Nadeau tanadeau at gmail.com
Sat Jan 23 12:57:20 CST 2016


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> wrote:

>
> > On Jan 23, 2016, at 10:24 AM, Trent Nadeau <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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160123/67820b27/attachment.html>


More information about the swift-evolution mailing list