tuples and metatypes


(Ray Fix) #1

Hi. Asking for a friend ;]

Tuples cannot conform to protocols or be extended because they are compound types. Is it correct to say that this is true because there is not a unique metatype for compound types? IOW, there is no unique existential container thingy for a tuples? (Not sure if I am using the proper vocabulary here or not.)

Thanks for your thoughts,
Ray Fix


(Quinn “The Eskimo!”) #2

The way I’ve seen this explained is that tuples are "structural types" (their compatibility is determined by their structure) and other types are "nominal types" (they can be named, and their compatibility is determined by that name).

<https://en.wikipedia.org/wiki/Nominal_type_system>

<https://en.wikipedia.org/wiki/Structural_type_system>

If you search various Swift resources (like the swift-evolution archive) for those terms you’ll find lots of interesting discussions.

Share and Enjoy

···

On 31 Aug 2016, at 02:38, Ray Fix via swift-users <swift-users@swift.org> wrote:

Is it correct to say that this is true because there is not a unique metatype for compound types?

--
Quinn "The Eskimo!" <http://www.apple.com/developer/>
Apple Developer Relations, Developer Technical Support, Core OS/Hardware