BT

What should Lambda Expressions in Visual Basic Look Like?

| by Jonathan Allen Follow 641 Followers on Dec 12, 2006. Estimated reading time: 1 minute |

In order to support LINQ, Visual Basic is adding support for lambda expressions. Lambda expressions are essentially inline functions and are a corner-stone of functional programming languages like Lisp and Haskell. As the next version of Visual Basic edges ever closer, certain syntactical issues need to be addressed.

On Friday, Paul Vick of Microsoft asked developers what syntax they want for this new capability. He presented three options.

The first is a very concise, C#-like syntax. 

1: C#-style, "x => x + 1" 

The second is more verbose, but also makes it clear that an in-line function is being used.

2: VB-style, "Function(x) x + 1" 

Finally there is a mixed style that uses a backslash, because it resembles a lambda, and C#'s => notation.

3: Hybrid-style, "\x => x + 1"

DiegoV has proposed a fourth syntax with some interesting characteristics. It uses the parameter binding operator (:=) and the parameter's name.

4: bar(x):=x+1

Surprisingly #2 seems to be getting the majority of the support right now. As Sriram Krishnan says,

Definitely #2 - one of the things I loved in VB was that I didn't have to rack my heads as to what a cryptic character meant - which I had to do often in Perl 

 

Rate this Article

Adoption Stage
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss
BT