diff --git a/proposals/csharp-12.0/collection-expressions.md b/proposals/csharp-12.0/collection-expressions.md index a6a7b62728..c618e82eeb 100644 --- a/proposals/csharp-12.0/collection-expressions.md +++ b/proposals/csharp-12.0/collection-expressions.md @@ -1275,81 +1275,3 @@ such types are valid `params` types when these APIs are declared public and are #### Conclusion Approved with modifications [LDM-2024-01-10](https://github.com/dotnet/csharplang/blob/main/meetings/2024/LDM-2024-01-10.md) - -## Design meetings -[design-meetings]: #design-meetings - -https://github.com/dotnet/csharplang/blob/main/meetings/2021/LDM-2021-11-01.md#collection-literals -https://github.com/dotnet/csharplang/blob/main/meetings/2022/LDM-2022-03-09.md#ambiguity-of--in-collection-expressions -https://github.com/dotnet/csharplang/blob/main/meetings/2022/LDM-2022-09-28.md#collection-literals -https://github.com/dotnet/csharplang/blob/main/meetings/2024/LDM-2024-01-08.md -https://github.com/dotnet/csharplang/blob/main/meetings/2024/LDM-2024-01-10.md - -## Working group meetings -[working-group-meetings]: #working-group-meetings - -https://github.com/dotnet/csharplang/blob/main/meetings/working-groups/collection-literals/CL-2022-10-06.md -https://github.com/dotnet/csharplang/blob/main/meetings/working-groups/collection-literals/CL-2022-10-14.md -https://github.com/dotnet/csharplang/blob/main/meetings/working-groups/collection-literals/CL-2022-10-21.md -https://github.com/dotnet/csharplang/blob/main/meetings/working-groups/collection-literals/CL-2023-04-05.md -https://github.com/dotnet/csharplang/blob/main/meetings/working-groups/collection-literals/CL-2023-04-28.md -https://github.com/dotnet/csharplang/blob/main/meetings/working-groups/collection-literals/CL-2023-05-26.md -https://github.com/dotnet/csharplang/blob/main/meetings/working-groups/collection-literals/CL-2023-06-12.md -https://github.com/dotnet/csharplang/blob/main/meetings/working-groups/collection-literals/CL-2023-06-26.md -https://github.com/dotnet/csharplang/blob/main/meetings/working-groups/collection-literals/CL-2023-08-03.md -https://github.com/dotnet/csharplang/blob/main/meetings/working-groups/collection-literals/CL-2023-08-10.md - -## Upcoming agenda items - -* Stack allocations for huge collections might blow the stack. Should the compiler have a heuristic for placing this data on the heap? Should the language be unspecified to allow for this flexibility? We should follow what the spec/impl does for [`params Span`](https://github.com/dotnet/csharplang/issues/1757). Options are: - - * Always stackalloc. Teach people to be careful with Span. This allows things like `Span span = [1, 2, ..s]` to work, and be fine as long as `s` is small. If this could blow the stack, users could always create an array instead, and then get a span around this. This seems like the most in line with what people might want, but with extreme danger. - * Only stackalloc when the literal has a *fixed* number of elements (i.e. no spread elements). This then likely makes things always safe, with fixed stack usage, and the compiler (hopefully) able to reuse that fixed buffer. However, it means things like `[1, 2, ..s]` would never be possible, even if the user knows it is completely safe at runtime. - -* How does overload resolution work? If an API has: - - ```C# - public void M(T[] values); - public void M(List values); - ``` - - What happens with `M([1, 2, 3])`? We likely need to define 'betterness' for these conversions. - -* Should we expand on collection initializers to look for the very common `AddRange` method? It could be used by the underlying constructed type to perform adding of spread elements potentially more efficiently. We might also want to look for things like `.CopyTo` as well. There may be drawbacks here as those methods might end up causing excess allocations/dispatches versus directly enumerating in the translated code. -* Generic type inference should be updated to flow type information to/from collection literals. For example: - - ```C# - void M(T[] values); - M([1, 2, 3]); - ``` - - It seems natural that this should be something the inference algorithm can be made aware of. Once this is supported for the 'base' constructible collection type cases (`T[]`, `I`, `Span` `new T()`), then it should also fall out of the `Collect(constructible_type)` case. For example: - - ```C# - void M(ImmutableArray values); - M([1, 2, 3]); - ``` - - Here, `Immutable` is constructible through an `init void Construct(T[] values)` method. So the `T[] values` type would be used with inference against `[1, 2, 3]` leading to an inference of `int` for `T`. - -* Cast/Index ambiguity. - - Today the following is an expression that is indexed into - - ```c# - var v = (Expr)[1, 2, 3]; - ``` - - But it would be nice to be able to do things like: - - ```c# - var v = (ImmutableArray)[1, 2, 3]; - ``` - - Can/should we take a break here? - -* Syntactic ambiguities with `?[`. - - It might be worthwhile to change the rules for `nullable index access` to state that no space can occur between `?` and `[`. That would be a breaking change (but likely minor as VS already forces those together if you type them with a space). If we do this, then we can have `x?[y]` be parsed differently than `x ? [y]`. - - A similar thing occurs if we want to go with https://github.com/dotnet/csharplang/issues/2926. In that world `x?.y` is ambiguous with `x ? .y`. If we require the `?.` to abut, we can syntactically distinguish the two cases trivially.