meetings/2023/LDM-2023-04-03.md
https://github.com/dotnet/csharplang/issues/7085
https://github.com/dotnet/csharplang/issues/5354
We started today by looking at open questions in collection literals, spending all of our time talking about the spread operator. We had a few questions we wanted answered about it:
For the first question, we universally agree that there is a concept to be explored there. There will be some syntax gremlins to iron out; some members believe that .. is perfectly
natural, as it is the complement of slicing in list patterns and in accessing sub-ranges of existing collections, while other members believe that .. is bad here because it
introduces confusion for collections of ranges. Despite that, we do think the space is worth exploring, and will do so.
Next, we thought about compiler optimizations of spreads. There's a lot of interesting side-points on optimizations here that can have a big impact on the collection literal, such as:
This last bullet brought up a new question that we then started delving into:
foreach'd over, we could just make it a stackalloc. Or, if it's
assigned to a var variable that is eventually passed to a List location, we could say that it's not really a list until that point, but is instead a lightweight list-like
thing.This idea is both interesting (gives us lots of room to optimize the implementation for specific scenarios) and terrifying (what is the type of this variable? What does generic type
inference do? Is it a quantum variable that needs to have the waveform collapse eventually?), and has lots of room to explore. We could say, for example, that var causes the type
to collapse, and it's only when these are used as nested expressions in other expressions that they have this weird quantum state. We think this needs to be explored more, and the
consequences and impacts on other systems thought through, before we go further down this road.
Finally, we also looked at the conditional expression used here. There are some older discussions on csharplang about making a conditional assignment as part of object initializers, we might be able to general purpose that to work in either of these cases. While we do think that the syntax originally proposed in the spec for collection literals should work and should ideally not produce excess allocations, it does feel ugly, and there's likely a feature to improve that for both collection literals and other types of initializers.
We'll come back after some more thinking on those topics has been done.
https://github.com/dotnet/csharplang/pull/7064
https://github.com/dotnet/csharplang/issues/1314
Finally today, we took an initial look through the first option proposed in 7064 for implementing safe fixed-size buffers. This is a more complicated proposal that builds off new
runtime support for InlineArrayAttribute, allowing types defined with a specific pattern to be treated as if they are fixed-size buffers of an element type. Today was mostly an
overview; next time we will go over the simpler version of the proposal (option 2) and discuss more about which option we want to go with.