14 comments

[ 3.2 ms ] story [ 40.8 ms ] thread
I for one am incredibly excited for both Pattern Matching and proper Tuples.

I have code bases that are about to become significantly shorter because of both. I do need to sit down and perform an analysis to understand the performance implications of this, thought I suspect there aren't many.

I'm not sure what to make of local functions. I've read and re-read about them but I still don't see the utility over a private function, unless they were intended to alleviate the performance issues that come with using a local Func<> inside of a method.

Agree, both of those features are very exciting and I'm looking forward to using them. The biggest feature I'm still missing from C# is a non-nullable reference type. I know there are various Nuget packages that add "Maybe" or "Optional" types, but they are no substitute for actually being a part of the language. Maybe one day...
That ship has already sailed.. anything they could do in the language now would just be like a user defined Optional. Youd still have to marshall the nullable refs into your pristine code
I'm torn about these features. On one hand I can see the usefullnes, but on the other hand I also expect them to be used in bad ways.

Pattern matching for example on types may indicate an OO design problem. Tuples may indicate an expression problem; often times a properly named class expresses intent much better.

As with any tool it is possible to misuse it, but pattern matching and tuples feel to me somehow as an especially fit tool to misuse.

The sweet spot for tuples are single-use cases local to a function, not global tuples flying around
Local functions look like they follow Python's reasons for avoiding anonymous functions in favor of nested functions.

It's a nice touch you can define the function at the end, looks clearer.

The only benefit over anonymos fns i see is avoiding allocation. Maybe there are attributes you cant easily put on anon fns as well
They should've called it Destructuring rather than Pattern Matching. Because when they want to add real pattern matching later theyll have to use a new keyword or confuse the concepts
Mutable tuples look like a really weird design choice. The most important reason I used tuples in python is the immutable semantic they have - this won't change.
Tuples are value types, so every new reference to a tuple is a copy. This avoids a lot of the situations you would normally get.