Among Visual Basic 2008's new features is the concept of closures. These allow programmers to access environments like locals, parameters and methods from more than one function. As Jared Parsons, a developer on the Visual Basic compiler and debugger, put it in a recent blog entry, "Closures are the underpinnings for several new features in Visual Basic  They are part of the guts of Lambda and Query expressions."
By submitting your email address, you agree to receive emails regarding relevant topic offers from TechTarget and its partners. You can withdraw your consent at any time. Contact TechTarget at 275 Grove Street, Newton, MA.
Parsons recently penned a five-part series that introduces programmers to closures in Visual Basic 2008.
Closures in VB, Part 1 explains how the compiler is able to make a variable available to more than one function. It is a process called "lifting the variable," Parsons notes.
Closures in VB, Part 2: Method Calls looks at the two types of method calls that closures tend to handle -- those that share a method or methods on a module and those that instantiate members of a class.
Closures in VB, Part 3: Scope discusses what happens when variables are lifted from different scopes. "The answer is that one closure class will be created for every unique scope where a lifted variable is declared and all of the variables in that scope that are lifted will be placed in that closure," Parsons indicates.
Closures in VB, Part 4: Variable Lifetime shows how, and why, the lifetime of a variable is tied to its scope. This was done so Visual Basic 2008 could support lambda expressions, he states.
Closures in VB, Part 5: Looping goes into some of the "unintended consequences" programmers may encounter when simultaneously using looping structures and lambda expressions and explains how to combat these problems.
Finally, for more insight into the new features of VB 2008, check out the Visual Basic 2008 tag on the VB Team blog.