> On Nov 21, 2017, at 6:02 PM, David Hart <da...@hartbit.com> wrote:
> 
> Can somebody explain to me what are 
>  nominal and structural types and why Optional should really be a structural 
> type?

Nominal types are structs, enums, protocols and classes. They have declarations 
in source and are uniquely identified by their name. Structural types are 
functions, meta types, protocol compositions, and tuples.

The distinction is not as clear as you might think because as Chris said, you 
can imagine tuple being implemented as ‘struct Tuple<T…>’, similarly functions 
and meta types could also be written as such. It is mostly a syntactic 
distinction in the language, but it has far-reaching consequences in internal 
representations, which is why for now it would be tricky to have structural 
types conform to protocols.

Slava
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to