[swift-evolution] Specify type of a delegate which conforms to a protocol

Ross O'Brien narrativium+swift at gmail.com
Thu Feb 11 07:56:17 CST 2016

For the sake of clarity: I had understood the term 'intersection type' to
be referring to the concept in the original post of this thread - a type
which conforms to one type and all of a given collection of protocols (i.e.
to be a valid value of this type an instance must conform to the
intersection of all of these things), and a 'union type' to conform to one
option in each series of options in a type.
e.g. if a type is a subclass of UIViewController and conforms to
UITableViewDataSource then - according to my misunderstanding - it would be
an eligible value for a variable of "intersection type"
all<UIViewController, UITableViewDataSource>, whereas if it conforms to
either UITableViewDataSource OR UITableViewDelegate then it would be
eligible for a variable of "union type" any<UIViewController,
(UITableViewDataSource | UITableViewDelegate)>. I got confused by the
terminology used in the thread (it sounded good).

So, to rephrase (hopefully) more correctly:
I think this proposal should stick with the 'all' type: a type which
inherits from at most one class and conforms to all of a specified
collection of protocols.

'any', intersection types, union types, and Either should be a different

On Thu, Feb 11, 2016 at 1:45 PM, Craig Cruden <ccruden at novafore.com> wrote:

> > On 2016-02-11, at 20:38:21, Ross O'Brien via swift-evolution <
> swift-evolution at swift.org> wrote:
> >
> > I think this proposal should stick to the intersection type: a type
> which inherits from at most one class (multiple inheritance should
> definitely be a separate proposal) if it conforms to all of one or more
> specified protocols.
> >
> > The next issue I'd see with the union type is that it's the already
> proposed Either type.
> >
> > — Ross
> Actually, no the union type has not been proposed.  It has been slightly
> talked about in the Either type discussion.  Either was a simple
> implementation that could do 80% of the use cases of type unions would
> allow (with 1% of the work :p).
> Whereas, union and intersection types are basically making changes to the
> type system itself — is it not?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160211/d97d8436/attachment.html>

More information about the swift-evolution mailing list