BT

New Early adopter or innovator? InfoQ has been working on some new features for you. Learn more

Future Plans for VB

| by Jonathan Allen on Dec 14, 2013. Estimated reading time: 2 minutes |

Lucian Wischik responded to Mads Torgersen’s talk with possible language changes for Visual Basic. These are just proposals, nothing is being promised yet. And they are mostly about reducing boilerplate code and don’t offer the kind of fundamental changes we saw in VB 10 or 11.

Read-Only Properties

Read-only auto properties are a natural fit for VB’s syntax. Simply prepend the ReadOnly keyword and it will ensure that only a setter is emitted while still allowing you to set the value in the constructor.

ReadOnly Property Name As String

Comments

Comments in VB currently don’t play well with implicit line continuations. So Lucian’s first VB-specific is to allow comments after an implicit line continuation.

Strings

Strings in Visual Basic currently don’t support multi-line. So the first proposed change is to simply allow that. It would work like C#’s verbatim strings, but without the need for a prefix.

A more interesting feature is String Interpolation. By using the $" prefix you eliminate the need for explicitly calling String.Format. This in turn eliminates errors caused by miscounting the number or position of the substitution variables. Here is an example:

Dim query = $"http://{ url }?name={ Escape(name) }&id={ Escape(id) }&o=xml"

About four years ago Miguel de Icaza proposed the string interpolation for C# and actually built a working prototype.

Literals

Date literals in Visual Basic are currently based on US common standards, which can be quite frustrating for non-US developers. So the proposed change is to simply allow ISO-formatted date literals as well.

Binary literals, already available in many other languages, is also being proposed. This would use the &B prefix and would be especially beneficial for bit-flag style enumerations.

Partial Interfaces and Modules

Not much to say here, the proposal is simple to allow for partial interfaces and modules. This would work the same way as for partial classes. As with partial classes this is mostly meant to be used with code generators.

Null Propagation

Like in C#, they are considering offering a null propagating operator. This would eliminate the need for a null check before invoking a method. Two options are currently on the table, the first being the same as we saw in C#. Note that in addition to ?. we also have ?().

Dim y As Integer = x?.y?(3)?.z

If there are any nulls to the left of a ?. or ?( operator, y gets the default value of z.

Function Parameters

As with C#, they would like to allow the params keyword to work with parameters of type IEnumerable instead of just arrays.

Also like C#, they would like to be able to declare local variables as part of out arguments.

If Integer.TryParse(s, Out x) Then

In this example the variable x would be created as if it were declared on the line above.

They are also thinking about declaring other variables inline,

If ( Dim x = GetValue()) > 15 Then Console .WriteLine(x)

Miscellaneous

Currently VB has a IsNot for reference comparisons, but not for type comparisons (i.e. TypeOf operator). This proposal would be simply closing that gap.

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

Bring back VB6 by S Ten

Microsoft should bring back an updated version of the VB6 programming language.
In .Net they should concentrate on C#
visualstudio.uservoice.com/forums/121579-visual...

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

1 Discuss

Login to InfoQ to interact with what matters most to you.


Recover your password...

Follow

Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.

Like

More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.

Notifications

Stay up-to-date

Set up your notifications and dont miss out on content that matters to you

BT