Proposed syntax for anonymous union types#6
Proposed syntax for anonymous union types#6michaelhkay wants to merge 1 commit intoexpath:masterfrom
Conversation
The syntax union(A, B, C) is added as a new kind of ItemType
|
|
Yes, it should be EQName. This is syntax for defining union types (in the XSD sense - unions of atomic types), which already have well-defined semantics because you can already use a named union type in a function signature or variable declaration. Unions of arbitrary item types (e.g. element() or attribute(), map or array) require a lot more work because the semantics need defining, e.g. the rules for item matching and type subsumption, the impact on the function conversion rules, etc etc. - so that's beyond the scope of this proposal. I don't foresee any major technical obstacles with doing it, but it's a significant piece of work to find all the implications. The impact on XSLT 3.0 streamability rules, for example, is a potential nightmare. |
|
That makes sense. I also like that the Note also that a union with union types should also be possible, not just atomic types (e.g. I will write a complementary proposal for using the |
|
Seems like a good proposal to me. Just wondering if the EBNF instead of (assuming @rhdunn's suggestion of EQName): LocalUnionType ::= "union" "(" EQName ("," EQName)* ")"Should/could be: LocalUnionType ::= "union" "(" EQName+ ")" |
|
I think that lists of names in XQuery/XPath are generally comma-separated rather than space-separated. There are a few cases of space separation, e.g. the list of keyword=value pairs in a decimal format declaration, but they are rather rare. (XSD of course uses space separation, and XSLT does so also in many attributes e.g. |
|
@michaelhkay Good point :-) |
|
I think this one is almost ready to Merge. @michaelhkay Do you want to address any of the comments from @rhdunn? @ChristianGruen Do you have any comments and/or objections? |
|
Looks good! |
|
Of my comments, the following remain relevant:
|
The syntax
union(A, B, C)is added as a new kind ofItemType