Lambda in VB

Don Box's Spoutlet

Syndication

I'm starting to write more VB code lately.

The XML support rocks.

More importantly, a huge amount of people who use the technology I work on see it through that lens, so I'd be an idiot not to walk in their shoes as much as possible.

I found the lambda syntax tonight.

Dim f As Func(Of Integer, Integer)

f = Function(a) a + 10

Very nice.

 


Posted Nov 11 2007, 10:37 PM by don-box

Comments

Jeff wrote re: Lambda in VB
on 11-12-2007 6:53 AM
is there a syntax for a multi-line lambda in VB?
Jürgen Pfeifer wrote re: Lambda in VB
on 11-13-2007 3:06 PM
Hi Don,
good to see that others are giving the new VB a serious try:-) BTW, did you find anything about iterators in VB? I found no equivalent to the C# yield statement up to now, but maybe I missed something...
Jonathan Allen wrote re: Lambda in VB
on 11-13-2007 9:08 PM
Jeff,
VB doesn't support multi-line lambdas, yet.

Jurgen,
Currently VB doesn't support it, and I haven't heard any plans to do so in the future.


Personally I would like to see both.
Tim wrote re: Lambda in VB
on 11-16-2007 12:37 AM
Hey Done, glad to hear you like what you see! VB's got some powerful inference for lambda expressions : check out my msdn article for more info.

In short, we allow left-to-right inference of argument types from delegate signatures (like you have), but we also allow right-to-left inference and we generate anonymous delegate types for you based on your lambda definition.

You can even go typeless and get VB latebinding.

http://msdn.microsoft.com/msdnmag/issues/07/09/BasicInstincts/

Add a Comment

(required)  
(optional)
(required)  
Remember Me?