qt4cg / qtspecs

QT4 specifications
https://qt4cg.org/
Other
28 stars 15 forks source link

Records: Introduction? #1494

Open ChristianGruen opened 1 week ago

ChristianGruen commented 1 week ago

It has been reported to me that the XQuery specification provides a nice and compact introduction on maps and arrays, but there currently is no comparable introduction for records yet. The “Changes” section on 3.2.8.3 Record Type gives a hint: It contains the sentence “Record types are added as a new kind of ItemType, constraining the value space of maps.”.

In addition, maybe we could rename the section Named Record Types to “Record Declaration”, analogous to “Variable Declaration”, “Context Value Declaration” and “Function Declaration(s)”. “Item Type Declarations” could be renamed to “Type Declaration”.

michaelhkay commented 2 days ago

When you say there's a "nice and compact introduction on maps and arrays", I'm not quite sure what you are referring to. The first substantive mention of maps is in 2.1.1 Values, which is just a forwards reference "Maps (see [4.13.1 Maps]and arrays (see [4.13.2 Arrays] are specific kinds of [function item]s." 4.13.1 is a very terse introduction that doesn't even refer to the XDM specification. Long before that we encounter 3.2.8.2 Map Types, which assumes you already know what maps are, and the highly technical 3.3.2.8 (titled Maps, but actually about Map subtype relationships).

So I think there's rather a challenge in finding a good place for the proposed introduction. Putting such material in the XDM spec, which is probably the most logical place, isn't going to reach a lot of readers.

ChristianGruen commented 2 days ago

When you say there's a "nice and compact introduction on maps and arrays", I'm not quite sure what you are referring to.

Good question; I would need to ask back ;)

Looking at the prose, 4.14 Maps and Arrays could be the most appropriate candidate:

“Most modern programming languages have support for collections of key/value pairs, which may be called maps, dictionaries, associative arrays, hash tables, keyed lists, or objects (these are not the same thing as objects in object-oriented systems). In XQuery 4.0, we call these maps. Most modern programming languages also support ordered lists of values, which may be called arrays, vectors, or sequences. In XQuery 4.0, we have both sequences and arrays. […]”

So I think there's rather a challenge in finding a good place for the proposed introduction.

Maybe the section above could be extended to “Maps, Arrays and Records” and some words could be added to explain how records relate to maps.

On the other hand, all this is a lot of extra work that someone would need to do. Perhaps it is generally better to tell everyone who is curious that the spec is aimed at implementers, and that there will be introductions, tutorials and books for those who want to use the language.