[Proposal]: Collection expressions
- Dominant language
- C#
- Stars
- 12.7k
- Forks
- 1.1k
- Avg merge
- 11h 1m
- Merged PRs (30d)
- 3
Description
# Collection expressions
* Specification: https://github.com/dotnet/csharplang/blob/main/proposals/csharp-12.0/collection-expressions.md
* Discussion: https://github.com/dotnet/csharplang/discussions/8651
## Summary
Collection expressions introduce a new terse syntax, `[e1, e2, e3, etc]`, to create common collection values. Inlining other collections into these values is possible using a spread operator `..` like so: `[e1, ..c2, e2, ..c2]`.
## Design meetings
- [Nov 1, 2021](https://github.com/dotnet/csharplang/blob/main/meetings/2021/LDM-2021-11-01.md#collection-literals): First look
- [Feb 9, 2022](https://github.com/dotnet/csharplang/blob/main/meetings/2022/LDM-2022-02-09.md#collection-literals): Triage
- [Mar 9, 2022](https://github.com/dotnet/csharplang/blob/main/meetings/2022/LDM-2022-03-09.md#ambiguity-of--in-collection-expressions): Ambiguity of `..`
- [Sep 28, 2022](https://github.com/dotnet/csharplang/blob/main/meetings/2022/LDM-2022-09-28.md#collection-literals): Triage
- [Apr 3, 2023](https://github.com/dotnet/csharplang/blob/main/meetings/2023/LDM-2023-04-03.md#collection-literals): Spreads and compiler optimizations
- [Apr 26, 2023](https://github.com/dotnet/csharplang/blob/main/meetings/2023/LDM-2023-04-26.md#collection-literals): Review, targeting `IEnumerable`, and dictionary elements
- [May 3, 2023](https://github.com/dotnet/csharplang/blob/main/meetings/2023/LDM-2023-05-03.md#collection-literal-natural-type): Natural type
- [May 31, 2023](https://github.com/dotnet/csharplang/blob/main/meetings/2023/LDM-2023-05-31.md): Review, construction strategies
- [Jun 19, 2023](https://github.com/dotnet/csharplang/blob/main/meetings/2023/LDM-2023-06-19.md#collection-literals): Type inference
- [Jul 12, 2023](https://github.com/dotnet/csharplang/blob/main/meetings/2023/LDM-2023-07-12.md#collection-literals): Create methods, extension methods
- [Jul 17, 2023](https://github.com/dotnet/csharplang/blob/main/meetings/2023/LDM-2023-07-17.md): Compiler check-in
- [Aug 9, 2023](https://github.com/dotnet/csharplang/blob/main/meetings/2023/LDM-2023-08-09.md#target-typing-of-collection-expressions-to-core-interfaces): Targeting interfaces, loosening Create return type requirements
- [Aug 14, 2023](https://github.com/dotnet/csharplang/blob/main/meetings/2023/LDM-2023-08-14.md): Span betterness, type inference, targeting interfaces or `Memory` or inline arrays
- [Aug 16, 2023](https://github.com/dotnet/csharplang/blob/main/meetings/2023/LDM-2023-08-16.md#ref-safety-scope-for-collection-expressions): Ref-safety scope
- [Sep 18, 2023](https://github.com/dotnet/csharplang/blob/main/meetings/2023/LDM-2023-09-18.md): Capacity optimization, buffering when length is known
- [Sep 20, 2023](https://github.com/dotnet/csharplang/blob/main/meetings/2023/LDM-2023-09-20.md): Spread type inference, overload resolution
- [Sep 25, 2023](https://github.com/dotnet/csharplang/blob/main/meetings/2023/LDM-2023-09-25.md#defining-well-defined-behavior-for-collection-expression-types): Well-defined behavior
- [Sep 27, 2023](https://github.com/dotnet/csharplang/blob/main/meetings/2023/LDM-2023-09-27.md): Allowed optimizations
- [Oct 2, 2023](https://github.com/dotnet/csharplang/blob/main/meetings/2023/LDM-2023-10-02.md): Conversions requiring Add, non-generic interfaces, strings
- [Oct 11, 2023](https://github.com/dotnet/csharplang/blob/main/meetings/2023/LDM-2023-10-11.md#collection-expressions): Preferring ReadOnlySpan over Span
- [Nov 15, 2023](https://github.com/dotnet/csharplang/blob/main/meetings/2023/LDM-2023-11-15.md#nullability-analysis-of-collection-expressions): Nullability analysis
- [Jan 8, 2024](https://github.com/dotnet/csharplang/blob/main/meetings/2024/LDM-2024-01-08.md): Determining iteration type
- [Jan 10, 2024](https://github.com/dotnet/csharplang/blob/main/meetings/2024/LDM-2024-01-10.md): Requiring construction APIs for convertibility
- [Jan 31, 2024](https://github.com/dotnet/csharplang/blob/main/meetings/2024/LDM-2024-01-31.md#relax-enumerable-requirement-for-collection-expressions): Relax enumerable requirement
- [Feb 5, 2024](https://github.com/dotnet/csharplang/blob/main/meetings/2024/LDM-2024-02-05.md#collection-expressions-inline-collections): Inline collections
- [Feb 26, 2024](https://github.com/dotnet/csharplang/blob/main/meetings/2024/LDM-2024-02-26.md#collection-expressions): Collections with iteration type of object with more specific Add
- [Apr 15, 2024](https://github.com/dotnet/csharplang/blob/main/meetings/2024/LDM-2024-04-15.md): Non-enumerable collections, relax Add requirement
- [Apr 17, 2024](https://github.com/dotnet/csharplang/blob/main/meetings/2024/LDM-2024-04-17.md#relax-add-requirement-for-collection-expression-conversions-to-types-implementing-ienumerable): Relax Add requirement
See also:
- [Better conversion from collection expression](https://github.com/dotnet/csharplang/issues/8374)
- [Collection expression arguments](https://github.com/dotnet/csharplang/issues/8887)
- [Dictionary Expressions](https://github.com/dotnet/csharplang/issues/8659)
## Working group meetings
- [Oct 6, 2022](https://github.com/dotnet/csharplang/blob/main/meetings/working-groups/collection-literals/CL-2022-10-06.md): Initial goals, dictionaries
- [Oct 14, 2022](https://github.com/dotnet/csharplang/blob/main/meetings/working-groups/collection-literals/CL-2022-10-14.md): Dictionaries, efficiency
- [Oct 21, 2022](https://github.com/dotnet/csharplang/blob/main/meetings/working-groups/collection-literals/CL-2022-10-21.md): Spans and stack allocation, review
- [Apr 5, 2023](https://github.com/dotnet/csharplang/blob/main/meetings/working-groups/collection-literals/CL-2023-04-05.md): Efficient construction for array-backed collections
- [Apr 28, 2023](https://github.com/dotnet/csharplang/blob/main/meetings/working-groups/collection-literals/CL-2023-04-28.md): Natural type, spread type inference, dictionary add vs overwrite
- [May 26, 2023](https://github.com/dotnet/csharplang/blob/main/meetings/working-groups/collection-literals/CL-2023-05-26.md): Construction API calls, dictionary sigils, C# 12 cut line
- [Jun 12, 2023](https://github.com/dotnet/csharplang/blob/main/meetings/working-groups/collection-literals/CL-2023-06-12.md): API shape for BCL collections to participate
- [Jun 26, 2023](https://github.com/dotnet/csharplang/blob/main/meetings/working-groups/collection-literals/CL-2023-06-26.md): Lifetimes, BCL APIs, breaking changes, extension methods, syntax disambiguation
- [Jul 26, 2023](https://github.com/dotnet/csharplang/blob/main/meetings/working-groups/collection-literals/CL-2023-07-26.md): Create methods with derived type, extension GetEnumerator, synthesized inline arrays
- [Aug 3, 2023](https://github.com/dotnet/csharplang/blob/main/meetings/working-groups/collection-literals/CL-2023-08-03.md): Escape scope, blittable data
- [Aug 10, 2023](https://github.com/dotnet/csharplang/blob/main/meetings/working-groups/collection-literals/CL-2023-08-10.md): Behavior on runtimes without inline arrays
- [Aug 11, 2023](https://github.com/dotnet/csharplang/blob/main/meetings/working-groups/collection-literals/CL-2023-08-11.md): Concrete types used when targeting interface types
- [Jan 23, 2024](https://github.com/dotnet/csharplang/blob/main/meetings/working-groups/collection-literals/CL-2024-01-23.md): Design restart
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.