InfoQ

News

Implicit line continuations in Visual Basic

Posted by Jonathan Allen on Feb 28, 2008 12:23 PM

Community
.NET
Topics
Language Design,
Syntax,
Programming
Tags
Visual Basic.NET

Line continuation characters have always been a wart on the VB syntax. Unlike languages in the Pascal and C families, Visual Basic does not require a trailing semi-colon to denote the end of a statement. The trade-off for this is that it does need a character to indicate when the statement does not end.

The line continuation character, an underscore, was introduced in Visual Basic 4. Prior to that, logical lines of code had to be on a single physical line of source code. This generally was more of a nuisance than a real problem unless you are using inline SQL. But with the introduction of LINQ one can easily foresee single query statements, especially ones with deep nesting, becoming quite problematic.

In a purely speculative post, Paul Vic of Microsoft is proposing to eliminate the need for continuation characters in most common cases. While VB, unlike SQL, cannot completely eliminate continuation characters it can get really close.

Paul's proposal would eliminate continuation characters in the following five situations:

  1. After binary operators in expression contexts.
  2. After the following punctuators: comma (","), open parenthesis ("("), open curly brace ("{"), begin embedded expression in XML ("<%=").
  3. Before the following punctuators: close parenthesis (")"), close curly brace ("}"), end embedded expression in XML ("%>").
  4. After an open angle bracket ("<") in an attribute context, before a close angle bracket (">") in an attribute context, and after a close angle bracket in a non-file-level attribute context (i.e. an attribute that does not specify "Assembly" or "Module").
  5. Before and after query expression operators.

Other ideas being kicked around by the community include

  • Before the Handles and Implements statements (and also after commas in those statements)
  • Between open " and closing " of a string :)

Allowing inline comments was also brought up. Currently VB does not support comments except at the end of a statement which making it difficult to document complex LINQ queries.

No comments

Reply

Exclusive Content

Rob Windsor on WCF with REST, JSON and RSS

WCF is not just for SOAP based services and can be used with popular protocols like RSS, REST and JSON. Join Rob Windsor as he introduces WCF 3.5 and its new native support for non-SOAP services.

Christophe Coenraets Discusses Flex 3, AIR, and BlazeDS

Christophe Coenraets discusses Flex 3, Flex Builder, AIR, BlazeDS, Adobe and open source, integrating Flex with existing applications, and integrating RIAs with search engines and browsers.

Debunking Common Refactoring Misconceptions

Danijel Arsenovski attempts to dispel some of the myths around refactoring and how it applies to .NET developers.

REST Eye for the SOA Guy

In this presentation, recorded at QCon San Francisco, CORBA guru Steve Vinoski explains REST from the view of someone who comes to SOA from a traditional, RPC-oriented background.

Choose Feature Teams over Component Teams for Agility

Feature teams are key to scaling agility for large teams. In an excerpt from "Scaling Lean and Agile Development," Larman & Vodde show how feature teams resolve traditional problems & raise new issues

Billy Newport explains Virtualization

Billy Newport talks about virtualization, eXtreme Transaction Processing (XTP) and WebSphere Virtual Enterprise. He discusses hardware, hypervisor, JVM, application and data virtualization.

Virtualization and Security

While virtualization provides many benefits, security can not be a forgotten concept in its application.

Introduction to Agile for Traditional Project Managers

This session is specifically aimed at traditionally trained project managers who are new to Agile, and who would like to be able to relate the PMI's best practices to their Agile equivalents.