-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A Proposal to Define Some Container-Related Terms #1250
Comments
Where to define any collection-related terms?Unless stated otherwise below, I propose we define the new terms in a new, top-level section in the Types chapter, called “Collection types”? |
Proposed term “collection”A collection is an ordered set of zero or more collection elements that can be used in a polymorphic way. Often, the elements are of the same data type such as |
Proposed term “collection type”An instance of a collection type can be used to represent a collection of elements of that type. Such a type shall be enumerable (§x.x.x) and it shall be at least one of the following:
A collection need not have a type that can be declared explicitly (not even using |
Proposed term “initializable collection type”[New/changed text is inside >>...<<.] Revise §12.8.17.4, “Collection initializers” |
Proposed term “indexable collection”An indexable collection is a collection in which any given element can be accessed via an index, and a contiguous subset of elements—referred to as a slice—can be denoted via a range.
To support indexing, a collection shall have an accessible indexer with the appropriate signature. If the indexer’s first argument has type |
Proposed term “countable type”A type is countable if it has an instance property named Q. All the standard container types used in/referenced by the C# spec are countable, but can we say/require that all container types must be countable? Does this definition belong here (it doesn’t mention containers), or should it go in 8.1, “General”? |
Future term “collection expression”This will be handled by the corresponding V12 feature draft PR. |
Future term “parameter collection”This will be handled by the corresponding V13 feature draft PR. |
Alternatives to “collection” as a generic English wordAssuming we want/need one or more terms involving the word “collection” to mean specific things, perhaps with respect to C#’s type system, how then do we refer to the generic English word “collection?” Consider the following spec text, from §6.4.1, “Tokens|General”:
Q. How about for generic uses of “collection” we use “set” instead (or possibly “group” if “set” implies a set-like collection [which is not a type in the CLI])? On the 2025-01-22 TG2 call, there was some opposition to "set;" "group" was less likely to be misleading/confusing. |
To add your input to the discussion of a topic in this issue, do NOT create a new comment; instead, locate the existing topic thread and add your contribution to its end using the “edit” option.
Introduction
The word “collection” is used in the draft-v8 C# spec 90-odd times; however, the spec does not contain a definition for this word as a term.
Although we’ve gotten along without such a definition, collection-related features will be added in V8 and future versions, and one more definitions might be desirable. Specifically:
And Bill is aware of other, potential future uses.
I propose that we define the term “collection” and some flavors thereof, and that we use them consistently starting with draft-v8.
Topics
The text was updated successfully, but these errors were encountered: