Insights and outlooks on software development

S'true

On syntactic sugar

Friday, July 17, 2009 by Thomas L

Previously, I've complained on the rocket operator in C# and the way it makes it hard for us to create nice, readable anonymous methods when doing the DSL dance in .NET/C#. Scala has about the same syntax, see this link. However, there seems to be a shorthand to declaring anonymous functions:

For those new to Scala, the expressions in parentheses are anonymous functions because they use "_" as identifiers. (_.bud) expands to (x => x.bud), where Scala chooses an x that is unique in the scope of the expression.

The same type of syntax could be allowed in C#; (x => x.IsValid) could be shortened to (_.IsValid). Unfortunately, I haven't heard that anything like this is in the pipe for C# 4.0.

Technorati Tags: ,,,,

Filed under , , having  

0 kommentarer: