ballerina-platform / ballerina-spec

Ballerina Language and Platform Specifications
Other
168 stars 53 forks source link

Precise semantics of intersecting types #344

Open hrennau opened 5 years ago

hrennau commented 5 years ago

Description: In several places, the operation of intersecting types is mentioned (for the first time in section 6.2.2, Contextually expected type). True, the statement "A type denotes a set of shapes" (5. Values, Types and Variables) might suffice for a definition, but Ballerina's type concept is very subtle, and I think a given set of shapes is not yet equivalent to a named type. (For example, I am not sure if a union type with a single member type is identical to that member type.) And I wonder what intersection might mean in "practical" (describable) terms if the participating types are not union types. So my suggestion is to introduce an explicit definition of type intersection and possibly also add a note illustrating the concept with examples. The best place would probably be section 5. Values, Types and Variables.

Suggested Labels: Type intersection

jclark commented 4 years ago

There are still some subtleties to be worked out. The idea is to use semantic subtyping, so intersection really does mean set intersection. See #86.