[HN Gopher] New in C# 10: Easier Lambda Expressions
       ___________________________________________________________________
        
       New in C# 10: Easier Lambda Expressions
        
       Author : FairDune
       Score  : 16 points
       Date   : 2021-11-26 21:18 UTC (1 hours ago)
        
 (HTM) web link (dontcodetired.com)
 (TXT) w3m dump (dontcodetired.com)
        
       | jayd16 wrote:
       | Here's a link to the official summary.
       | 
       | https://docs.microsoft.com/en-us/dotnet/csharp/language-refe...
       | 
       | Lambdas can also have attributes now, too.
        
       | tester756 wrote:
       | Nice, I like it.
       | 
       | I do wonder what was limiting them before
        
         | jayd16 wrote:
         | They added an explicit return type, which allows for the full
         | delegate type to be inferred.
        
         | ygra wrote:
         | Every feature starts out with -100 points. So there's always a
         | trade-off to do everything you can imagine to make every last
         | corner case nice or shipping something in a reasonable
         | timeframe. When lambda expressions were introduced they were
         | designed to work well together with LINQ and that whole part of
         | the language isn't a small one either. Storing a lambda
         | expression in a local variable is not such a common occurrence
         | to really _need_ type inference or the ability to add types to
         | lambda expressions.
         | 
         | Heck, I'd say, by now with local functions most lambdas that
         | previously would have been a local could now just be a local
         | function.
        
       | agluszak wrote:
       | There's something clearly wrong with the code samples: look at
       | the </string> "closing tags" which somehow sneaked in in line 17
       | of the first sample
        
         | mastax wrote:
         | The markdown parser of the "Reddit Sync" app adds closing tags
         | to things as well. Hasn't been annoying enough for me to
         | switch.
        
         | FairDune wrote:
         | Yeah, I tried those out in a scratch pad. They don't compile.
        
           | Sharlin wrote:
           | Seems the renderer has "helpfully" added closing tags for the
           | `<string ...>` generic parameter lists since they look like
           | *ml...
        
       | thrower123 wrote:
       | F# is really, really bleeding into C#. There'll be a convergence,
       | for all intents and purposes, by about C# 15 at this rate.
        
         | paavohtl wrote:
         | Ehhh, not really. It really depends on what you mean by
         | convergence. You could add every single one of F#'s features
         | into C#, and I still wouldn't consider them the to be same
         | language or the other to be irrelevant. The strength of F# is
         | the primary coding style: mostly functional, mostly immutable,
         | expression-based, strongly typed with global type inference.
         | The way most C# is written is almost the polar opposite: mostly
         | OOP/imperative, mostly mutable, statement-based, statically
         | typed but with a less expressive type system (no sum types,
         | exceptions and nulls over Result and Option) and very limited
         | local type inference.
         | 
         | The F# style is enabled by a set of features - some of would be
         | really hard to add to C# (such as currying and global type
         | inference) - but even if they were added, the millions(?) of C#
         | developers would be unlikely adopt the functional style just
         | because it was possible. A language is not just a list of
         | features; each language has its own culture and "idiomatic" way
         | of doing things.
        
       ___________________________________________________________________
       (page generated 2021-11-26 23:00 UTC)