OK, It’s been a few weeks, so this is likely not “new” news, but still.
Looks like MS isn’t backing off on VB one bit, and that’s a good thing. Heck, as I understand it, there’s even a project in skunkworks build VB in VB! I’ve always said the mark of a complete language is when it’s actually written in itself.
But I digress. Back to VB 11. The VB Team website has a nice rundown of some of the high points of the release here.
- Multi-line Lambdas. That’s right, you can finally declare a Function()….. lambda that spans multiple lines.
- Iterators. Which basically means a Yield keyword that can fall out of an iteration loop to allow the iterating code to perform it’s work.
- Caller info. This is a big one for me. I’ve written more than my share of error logging/trapping/handling frameworks over the years, starting with VB3, on through VB6 and then into .net. Unfortunately, this feature has nothing to do with that!
Caller info allows a function to easily and straightforwardly retrieve the Name, Line number or FilePath, of the calling function. While the Line number and Calling path are of dubious value, the caller name is incredibly powerful for things like front ending field accessors in data access libraries. Say you have a small function that retrieves a value from a VB, via a name. With this feature, you can easily create properties of an object that are named that name and then pass the property name down to the accessor function to retrieve the value.
This has been doable for ever in .net as well (via the call stack), but was not straightforward and was susceptible to corruption if you used code obfuscators. No word on whether this feature will play better with obfuscators at this point, though.
- Call View Hierarchy. Looks like a very nice feature, but I’ll have to play with it more before making any concrete observations.
- Global Namespace. Another meh. On some projects, I could see this being handy. But it’s nothing to get too excited over. A very incremental improvement.
- Unsafe code. At least, I’ve seen no mention of it.
- Property-level scope. They added auto properties in VB10. Property-level scope seems like the next natural step for that. And by this, I mean:
Public Property Name() as string
Private _Name as string <—– Property level scope
EDIT: The suggestion that I posted to MS’s suggestion board ended up getting a comment from Lucian Wischik. You can read his full comments here.
Property Scope Variables
- More Dynamic functionality, though you could argue that you can actually do quite a lot of dynamic stuff now in .net languages.
It’s good to see the language getting very close to parity with C#, and the news of a forthcoming VB.net coded compiler is even more exciting.