{"id":2933,"date":"2009-03-27T12:00:00","date_gmt":"2009-03-27T12:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/vbteam\/2009\/03\/27\/implicit-line-continuation-in-vb-10-tyler-whitney\/"},"modified":"2024-07-05T13:31:05","modified_gmt":"2024-07-05T20:31:05","slug":"implicit-line-continuation-in-vb-10-tyler-whitney","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/vbteam\/implicit-line-continuation-in-vb-10-tyler-whitney\/","title":{"rendered":"Implicit Line Continuation in VB 10 (Tyler Whitney)"},"content":{"rendered":"<p class=\"MsoNormal\"><font face=\"Calibri\" size=\"3\">Things are always changing.<span>&nbsp; <\/span>I was at the Washington State History Museum with my daughter a couple weeks ago.<span>&nbsp; <\/span>One of the exhibits features pictures of various sites that were taken many years ago.<span>&nbsp; <\/span>Then it contrasts them with contemporary pictures taken of the same locations.<span>&nbsp; <\/span>It was really interesting how <i>much<\/i> things changed and how quickly. <\/font><\/p>\n<p class=\"MsoNormal\"><font size=\"3\"><font face=\"Calibri\">I have a couple computers in my office that I had when I was a kid.<span>&nbsp; <\/span>My wife suggested that I move my little museum to a place where it would be more appreciated&mdash;which meant out of the house \ud83d\ude09<span>&nbsp; <\/span>So here they sit in my office.<span>&nbsp; <\/span>I have an Apple ][+ that is signed by Stephen Wozniak.<span>&nbsp; <\/span>He was on campus some time ago and he graciously signed it for me. <span>&nbsp;<\/span>But the reason I bring it up is because every once in a while I fire it up to remember what the programming experience was like, way back when.<span>&nbsp; <\/span>Having that machine in my office is a nostalgic reminder of how things change.<span>&nbsp; <\/span><\/font><\/font><\/p>\n<p class=\"MsoNormal\"><font size=\"3\"><font face=\"Calibri\">And Visual Basic has certainly seen its share of change.<span>&nbsp; <\/span>It&rsquo;s in the context of some of my current work on the VB compiler team that I thought I&rsquo;d write about a <i>little<\/i> change we are doing for Dev 10.<span>&nbsp; <\/span><\/font><\/font><\/p>\n<p class=\"MsoNormal\"><i><font size=\"3\"><font face=\"Calibri\">What&rsquo;s in a line<\/p>\n<p><\/font><\/font><\/i><\/p>\n<p class=\"MsoNormal\"><font face=\"Calibri\" size=\"3\">VB is a line-oriented language.<span>&nbsp; <\/span>That is, we use the carriage return as our statement termination token.<span>&nbsp; <\/span>You are no doubt familiar with other languages that use an explicit statement terminator&#8211;like C which uses the &lsquo;;&rsquo;.<span>&nbsp; <\/span>A carriage return in VB is, for the purposes of analogy anyway, similar to the &lsquo;;&rsquo; in C*.<span>&nbsp; <\/span>But why have a statement terminator symbol in the first place?<\/font><\/p>\n<p class=\"MsoNormal\"><font face=\"Calibri\" size=\"3\">One reason is ambiguity.<span>&nbsp; <\/span>A common complaint about compilers is that if the compiler knows that the terminator is missing why not put it in for you rather than bother you with an error?<span>&nbsp; <\/span>Part of the reason is that it isn&rsquo;t necessarily clear where it should go.<span>&nbsp; <\/span>The compiler has just reached the end of the road, as far as the current statement goes, and there may have been multiple places along the way where a terminator could have made sense.<span>&nbsp; <\/span>If the compiler silently inserted it for you it may be right part of the time.<span>&nbsp; <\/span>But it could also be wrong&#8211; silently changing the meaning of your program in ways you didn&rsquo;t expect.<\/font><\/p>\n<p class=\"MsoNormal\"><font face=\"Calibri\" size=\"3\">I tried to explain why we have statement terminator tokens in a recent <a class=\"\" href=\"https:\/\/channel9.msdn.com\/posts\/funkyonex\/No-More-Underscrores-in-Visual-Basic-10\/\" target=\"_blank\" rel=\"noopener\">Channel 9 interview<\/a>.<span>&nbsp; <\/span>The example I used went something like this:<\/font><\/p>\n<p class=\"MsoNormal\"><font size=\"3\"><font face=\"Calibri\"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>On Thursday Beth coded feature1 and feature2 and feature3 on Friday.<\/font><\/font><\/p>\n<p class=\"MsoNormal\"><font face=\"Calibri\" size=\"3\">It&rsquo;s a bad sentence.<span>&nbsp; <\/span>But the issue I&rsquo;ll focus on is ambiguity.<span>&nbsp; <\/span>When did feature2 get written?<span>&nbsp; <\/span>It could have been on Thursday.<span>&nbsp; <\/span>It could have been on Friday.<span>&nbsp; <\/span>We can fix the ambiguity with some punctuation.<\/font><\/p>\n<p class=\"MsoNormal\"><font size=\"3\"><font face=\"Calibri\"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>On Thursday Beth coded feature1 and feature2.<span>&nbsp; <\/span>And feature3 on Friday.<\/font><\/font><\/p>\n<p class=\"MsoNormal\"><font face=\"Calibri\" size=\"3\">It&rsquo;s still ugly.<span>&nbsp; <\/span>But punctuation at least addresses the ambiguity issue.<\/font><\/p>\n<p class=\"MsoNormal\"><font face=\"Calibri\" size=\"3\">We have the same problem in programming languages.<span>&nbsp; <\/span>For instance, what does this mean:<\/font><\/p>\n<p class=\"MsoNormal\"><i><font size=\"3\"><font face=\"Calibri\">Return<span>&nbsp; <\/span>1 <\/p>\n<p><\/font><\/font><\/i><\/p>\n<p class=\"MsoNormal\"><i><font size=\"3\"><font face=\"Calibri\">+foo()<\/p>\n<p><\/font><\/font><\/i><\/p>\n<p class=\"MsoNormal\">\n<p><font face=\"Calibri\" size=\"3\">&nbsp;<\/font><\/p>\n<\/p>\n<p class=\"MsoNormal\"><font face=\"Calibri\" size=\"3\">Does it mean <i>Return 1<\/i>, or does it mean <i>Return 1+foo()<\/i>?<\/font><\/p>\n<p class=\"MsoNormal\"><font face=\"Calibri\" size=\"3\">We can avoid the ambiguity by introducing punctuation to mark the end of each statement, e.g:<\/font><\/p>\n<p class=\"MsoNormal\"><i><font size=\"3\"><font face=\"Calibri\">Return 1;<\/p>\n<p><\/font><\/font><\/i><\/p>\n<p class=\"MsoNormal\"><i><font size=\"3\"><font face=\"Calibri\">+foo();<\/p>\n<p><\/font><\/font><\/i><\/p>\n<p class=\"MsoNormal\"><i><\/p>\n<p><font face=\"Calibri\" size=\"3\">&nbsp;<\/font><\/p>\n<p><\/i><\/p>\n<p class=\"MsoNormal\"><i><font size=\"3\"><font face=\"Calibri\">To terminate or not to terminate: that is the question<\/p>\n<p><\/font><\/font><\/i><\/p>\n<p class=\"MsoNormal\"><font face=\"Calibri\" size=\"3\">When you first consider the issue of allowing whitespace in a line oriented language like VB, it seems like it would boil down to letting the scanner eat all of the whitespace and be done with it.<span>&nbsp; <\/span>But the problem is more complex.<span>&nbsp; <\/span>One way to think about the issue is to put the same problem in a different context. <\/font><\/p>\n<p class=\"MsoNormal\"><font face=\"Calibri\" size=\"3\">VB uses the carriage return as a statement terminator.<span>&nbsp; <\/span>C# uses the semi-colon.<span>&nbsp; <\/span>Attempting to make VB read through carriage returns as if they were expendable whitespace is similar to getting C# to read through semi-colons as if they didn&rsquo;t always mean we are at the end of a statement.<span>&nbsp; <\/span>Parsing through carriage returns in VB for this:<\/font><\/p>\n<p class=\"MsoNormal\"><font size=\"3\"><font face=\"Calibri\"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><i>Dim x as integer = 1 +<\/p>\n<p><\/i><\/font><\/font><\/p>\n<p class=\"MsoNormal\"><i><font size=\"3\"><font face=\"Calibri\"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>2<\/p>\n<p><\/font><\/font><\/i><\/p>\n<p class=\"MsoNormal\">\n<p><font face=\"Calibri\" size=\"3\">&nbsp;<\/font><\/p>\n<\/p>\n<p class=\"MsoNormal\"><font face=\"Calibri\" size=\"3\">Is roughly like trying to parse this in C#<\/font><\/p>\n<p class=\"MsoNormal\">\n<p><font face=\"Calibri\" size=\"3\">&nbsp;<\/font><\/p>\n<\/p>\n<p class=\"MsoNormal\"><font size=\"3\"><font face=\"Calibri\"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><i>int x =<span>&nbsp; <\/span>1 +;<\/p>\n<p><\/i><\/font><\/font><\/p>\n<p class=\"MsoNormal\"><font size=\"3\"><font face=\"Calibri\"><i><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>2;<\/i><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/font><\/font><\/p>\n<p class=\"MsoNormal\">\n<p><font face=\"Calibri\" size=\"3\">&nbsp;<\/font><\/p>\n<\/p>\n<p class=\"MsoNormal\"><font face=\"Calibri\" size=\"3\">The problem is being able to tell when a statement completion token means that we are at the end of the statement vs. when it doesn&rsquo;t.<span>&nbsp; <\/span>We have to approach an existing grammar and decide how to provide this flexibility without creating a lot of risk for all the existing code out there that will be compiled by the new compiler.<\/font><\/p>\n<p class=\"MsoNormal\"><font size=\"3\"><font face=\"Calibri\"><i><span>&nbsp;<\/span><\/i>We decided to mitigate risk and keep the feature simple by limiting implicit line continuation to easy-to-understood cases.<span>&nbsp; <\/span>We choose tokens where it would be easy to infer that an implicit line continuation could occur.<span>&nbsp; <\/span>For instance, it is clear that <i>x = 1+<\/i><span>&nbsp; <\/span>isn&rsquo;t a &lsquo;finished&rsquo; statement.<span>&nbsp; <\/span>So when we parse the &lsquo;+&rsquo; we will peek through the statement terminator (the carriage return) to see if we can continue the expression. <\/font><\/font><\/p>\n<p class=\"MsoNormal\"><font face=\"Calibri\" size=\"3\">We don&rsquo;t capture every scenario.<span>&nbsp; <\/span>Given our cost and time constraints around the feature, we tried to capture the most common cases that would provide the most bang for the buck.<span>&nbsp; <\/span>We also avoided the ones that just led to problems.<span>&nbsp; <\/span>Here are some examples of problems you could have if we had decided to allow implicit continuation anywhere.<span>&nbsp; <\/span>I take these from some analysis that Lucian Wischik (also on the VB compiler team) did on our grammar:<\/font><\/p>\n<p class=\"MsoNormal\"><i><font size=\"3\"><font face=\"Calibri\">With y<\/p>\n<p><\/font><\/font><\/i><\/p>\n<p class=\"MsoNormal\"><i><font size=\"3\"><font face=\"Calibri\"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>A=x<\/p>\n<p><\/font><\/font><\/i><\/p>\n<p class=\"MsoNormal\"><i><font size=\"3\"><font face=\"Calibri\"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>.xfield<\/p>\n<p><\/font><\/font><\/i><\/p>\n<p class=\"MsoNormal\"><i><font size=\"3\"><font face=\"Calibri\">End With<\/p>\n<p><\/font><\/font><\/i><\/p>\n<p class=\"MsoNormal\">\n<p><font face=\"Calibri\" size=\"3\">&nbsp;<\/font><\/p>\n<\/p>\n<p class=\"MsoNormal\"><font face=\"Calibri\" size=\"3\">If we allowed implicit continuation before the &lsquo;.&rsquo; we would have problems knowing what the period belongs to.<span>&nbsp; <\/span>For example, it could be interpreted as:<\/font><\/p>\n<p class=\"MsoNormal\"><font size=\"3\"><font face=\"Calibri\"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><i>With y<\/p>\n<p><\/i><\/font><\/font><\/p>\n<p class=\"MsoNormal\"><i><font size=\"3\"><font face=\"Calibri\"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>A=x.xield<\/p>\n<p><\/font><\/font><\/i><\/p>\n<p class=\"MsoNormal\"><i><font size=\"3\"><font face=\"Calibri\"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>End With<\/p>\n<p><\/font><\/font><\/i><\/p>\n<p class=\"MsoNormal\"><font face=\"Calibri\" size=\"3\">Or<\/font><\/p>\n<p class=\"MsoNormal\"><font size=\"3\"><font face=\"Calibri\"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><i>With y<\/p>\n<p><\/i><\/font><\/font><\/p>\n<p class=\"MsoNormal\"><i><font size=\"3\"><font face=\"Calibri\"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>A=x<\/p>\n<p><\/font><\/font><\/i><\/p>\n<p class=\"MsoNormal\"><i><font size=\"3\"><font face=\"Calibri\"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>.xfield <\/p>\n<p><\/font><\/font><\/i><\/p>\n<p class=\"MsoNormal\"><i><font size=\"3\"><font face=\"Calibri\"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&amp;nbs\np; <\/span>End With<\/p>\n<p><\/font><\/font><\/i><\/p>\n<p class=\"MsoNormal\">\n<p><font face=\"Calibri\" size=\"3\">&nbsp;<\/font><\/p>\n<\/p>\n<p class=\"MsoNormal\"><font face=\"Calibri\" size=\"3\">If we allowed whitespace after every keyword, we could run into problems where a set of tokens could be interpreted in different ways:<\/font><\/p>\n<p class=\"MsoNormal\">\n<p><font face=\"Calibri\" size=\"3\">&nbsp;<\/font><\/p>\n<\/p>\n<p class=\"MsoNormal\"><i><font size=\"3\"><font face=\"Calibri\">Do<\/p>\n<p><\/font><\/font><\/i><\/p>\n<p class=\"MsoNormal\"><i><font size=\"3\"><font face=\"Calibri\"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>While condition<\/p>\n<p><\/font><\/font><\/i><\/p>\n<p class=\"MsoNormal\"><i><font size=\"3\"><font face=\"Calibri\"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>End While <\/p>\n<p><\/font><\/font><\/i><\/p>\n<p class=\"MsoNormal\"><i><font face=\"Calibri\" size=\"3\">Loop<\/font><\/i><\/p>\n<p class=\"MsoNormal\">\n<p><font face=\"Calibri\" size=\"3\">&nbsp;<\/font><\/p>\n<\/p>\n<p class=\"MsoNormal\"><font face=\"Calibri\" size=\"3\">Could also be interpreted as:<\/font><\/p>\n<p class=\"MsoNormal\">\n<p><font face=\"Calibri\" size=\"3\">&nbsp;<\/font><\/p>\n<\/p>\n<p class=\"MsoNormal\"><font size=\"3\"><font face=\"Calibri\"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><i>Do While condition<\/p>\n<p><\/i><\/font><\/font><\/p>\n<p class=\"MsoNormal\"><i><font face=\"Calibri\"><font size=\"3\"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>End While <\/font><\/font><\/i><i><font size=\"3\"><span><span>&szlig;<\/span><\/span><font face=\"Calibri\"> this would become a syntax error<\/p>\n<p><\/font><\/font><\/i><\/p>\n<p class=\"MsoNormal\"><i><font size=\"3\"><font face=\"Calibri\"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Loop <\/p>\n<p><\/font><\/font><\/i><\/p>\n<p class=\"MsoNormal\">\n<p><font face=\"Calibri\" size=\"3\">&nbsp;<\/font><\/p>\n<\/p>\n<p class=\"MsoNormal\"><font face=\"Calibri\" size=\"3\">Here&rsquo;s some more fun with keywords and whitespace.<span>&nbsp; <\/span>Given the following:<\/font><\/p>\n<p class=\"MsoNormal\">\n<p><font face=\"Calibri\" size=\"3\">&nbsp;<\/font><\/p>\n<\/p>\n<p class=\"MsoNormal\"><font size=\"3\"><font face=\"Calibri\"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><i>Do<\/p>\n<p><\/i><\/font><\/font><\/p>\n<p class=\"MsoNormal\"><i><font size=\"3\"><font face=\"Calibri\"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Loop <\/p>\n<p><\/font><\/font><\/i><\/p>\n<p class=\"MsoNormal\"><i><font size=\"3\"><font face=\"Calibri\">Until <\/p>\n<p><\/font><\/font><\/i><\/p>\n<p class=\"MsoNormal\"><i><font size=\"3\"><font face=\"Calibri\">Foo<\/p>\n<p><\/font><\/font><\/i><\/p>\n<p class=\"MsoNormal\">\n<p><font face=\"Calibri\" size=\"3\">&nbsp;<\/font><\/p>\n<\/p>\n<p class=\"MsoNormal\"><font face=\"Calibri\" size=\"3\">Should it be interpreted as:<\/font><\/p>\n<p class=\"MsoNormal\"><i><font size=\"3\"><font face=\"Calibri\"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Do<\/p>\n<p><\/font><\/font><\/i><\/p>\n<p class=\"MsoNormal\"><i><font size=\"3\"><font face=\"Calibri\"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Loop Until Foo<\/p>\n<p><\/font><\/font><\/i><\/p>\n<p class=\"MsoNormal\">\n<p><font face=\"Calibri\" size=\"3\">&nbsp;<\/font><\/p>\n<\/p>\n<p class=\"MsoNormal\"><font face=\"Calibri\" size=\"3\">Or instead as:<\/font><\/p>\n<p class=\"MsoNormal\">\n<p><font face=\"Calibri\" size=\"3\">&nbsp;<\/font><\/p>\n<\/p>\n<p class=\"MsoNormal\"><font size=\"3\"><font face=\"Calibri\"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><i>Do<\/p>\n<p><\/i><\/font><\/font><\/p>\n<p class=\"MsoNormal\"><i><font size=\"3\"><font face=\"Calibri\"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Loop<\/p>\n<p><\/font><\/font><\/i><\/p>\n<p class=\"MsoNormal\"><i><font face=\"Calibri\"><font size=\"3\"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Until <\/font><\/font><\/i><i><font size=\"3\"><span><span>&szlig;<\/span><\/span><font face=\"Calibri\"> a method call<\/p>\n<p><\/font><\/font><\/i><\/p>\n<p class=\"MsoNormal\"><i><font face=\"Calibri\"><font size=\"3\"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Foo <\/font><\/font><\/i><i><font size=\"3\"><span><span>&szlig;<\/span><\/span><font face=\"Calibri\"> another method call<\/p>\n<p><\/font><\/font><\/i><\/p>\n<p class=\"MsoNormal\">\n<p><font face=\"Calibri\" size=\"3\">&nbsp;<\/font><\/p>\n<\/p>\n<p class=\"MsoNormal\"><font face=\"Calibri\" size=\"3\">And finally for a (even more) contrived example:<\/font><\/p>\n<p class=\"MsoNormal\">\n<p><font face=\"Calibri\" size=\"3\">&nbsp;<\/font><\/p>\n<\/p>\n<p class=\"MsoNormal\"><i><font size=\"3\"><font face=\"Calibri\">Sub Main()<\/p>\n<p><\/font><\/font><\/i><\/p>\n<p class=\"MsoNormal\"><i><font size=\"3\"><font face=\"Calibri\">End<\/p>\n<p><\/font><\/font><\/i><\/p>\n<p class=\"MsoNormal\"><i><font face=\"Calibri\" size=\"3\">Sub<\/font><\/i><\/p>\n<p class=\"MsoNormal\">\n<p><font face=\"Calibri\" size=\"3\">&nbsp;<\/font><\/p>\n<\/p>\n<p class=\"MsoNormal\"><font face=\"Calibri\" size=\"3\">Is this an <i>End<\/i> statement inside a <i>Sub Main()<\/i>and the user has just started typing in a new <i>Sub<\/i>?<span>&nbsp; <\/span>Or is it <i>End Sub<\/i>? Remember that we don&rsquo;t just get to parse the finished text.<span>&nbsp; <\/span>We have to parse as the user is entering the text in the first place so we can offer appropriate Intellisense.<\/font><\/p>\n<p class=\"MsoNormal\">\n<p><font face=\"Calibri\" size=\"3\">&nbsp;<\/font><\/p>\n<\/p>\n<p class=\"MsoNormal\"><font size=\"3\"><font face=\"Calibri\">And so it goes for other examples.<span>&nbsp; <\/span><\/font><\/font><\/p>\n<p class=\"MsoNormal\">\n<p><font face=\"Calibri\" size=\"3\">&nbsp;<\/font><\/p>\n<\/p>\n<p class=\"MsoNormal\"><font face=\"Calibri\" size=\"3\">There is still a place for the explicit line continuation character.<span>&nbsp; <\/span>You may have occasion to use it when you want to split a line in way that implicit line continuation doesn&rsquo;t accommodate.<span>&nbsp; <\/span><span>&nbsp;<\/span>For instance:<\/font><\/p>\n<p class=\"MsoNormal\">\n<p><font face=\"Calibri\" size=\"3\">&nbsp;<\/font><\/p>\n<\/p>\n<p class=\"MsoNormal\"><font size=\"3\"><font face=\"Calibri\">&lsquo;This works:<\/p>\n<p><\/font><\/font><\/p>\n<p class=\"MsoNormal\"><i><font size=\"3\"><font face=\"Calibri\">Dim list As New List(Of Integer) From <\/p>\n<p><\/font><\/font><\/i><\/p>\n<p class=\"MsoNormal\"><i><font size=\"3\"><font face=\"Calibri\">{1, 2, 3, 4, 5}<\/p>\n<p><\/font><\/font><\/i><\/p>\n<p class=\"MsoNormal\"><font size=\"3\"><font face=\"Calibri\"><span>&nbsp;<\/span><\/p>\n<p><\/font><\/font><\/p>\n<p class=\"MsoNormal\"><font face=\"Calibri\" size=\"3\">But the following doesn&rsquo;t because we don&rsquo;t allow a continuation before the <i>From<\/i> keyword in this context.<span>&nbsp; <\/span>We need to use an explicit line continuation here:<\/font><\/p>\n<p class=\"MsoNormal\"><span><font face=\"Calibri\" size=\"3\"><\/font><\/span>&nbsp;<\/p>\n<p class=\"MsoNormal\"><i><font size=\"3\"><font face=\"Calibri\">Dim list As New List(Of Integer) _<\/p>\n<p><\/font><\/font><\/i><\/p>\n<p class=\"MsoNormal\"><i><font size=\"3\"><font face=\"Calibri\">From {1, 2, 3, 4, 5}<\/p>\n<p><\/font><\/font><\/i><\/p>\n<p class=\"MsoNormal\">\n<p><font face=\"Calibri\" size=\"3\">&nbsp;<\/font><\/p>\n<\/p>\n<p class=\"MsoNormal\"><i><span>So sweet was ne&#8217;er so fatal &ndash; Othello Act V, Sc. II<\/span><\/p>\n<p><\/i><\/p>\n<p class=\"MsoNormal\"><font face=\"Calibri\" size=\"3\">I was asked a question on the Channel 9 interview about how this feature is tested since it seems like it could be one of these hair-pulling things to make sure we haven&rsquo;t broken anything.<\/font><\/p>\n<p class=\"MsoNormal\"><font face=\"Calibri\" size=\"3\">One help is that we have the advantage of having a good test bed.<span>&nbsp; <\/span>For language specific tests alone, we have about 25,000 tests covering 1.4 million scenarios.<span>&nbsp; <\/span>Our testers created a tool that can inject carriage returns into some of our existing tests after the tokens we know can imply line continuation.<span>&nbsp; <\/span>Then the test is run to make sure it compiles and runs the same way it did before.<span>&nbsp; <\/span>There is also the testing that is done by a tester armed with the spec and the grammar, who tries to find ways to break the compiler and the intellisense experience.<span>&nbsp; <\/span>Tests are also hand-crafted to test various line-continuation scenarios.<\/font><\/p>\n<p class=\"MsoNormal\"><font face=\"Calibri\" size=\"3\">It is gratifying to finally get implicit line continuation into the language.<span>&nbsp; <\/span>There has been a desire to do it for some time, but it usually had to take a place in line behind other priorities.<span>&nbsp; <\/span>But now it will see the light of day. <\/font><\/p>\n<p class=\"MsoNormal\"><font face=\"Calibri\" size=\"3\">It&rsquo;s fascinating how things have changed over the years.<span>&nbsp; <\/span>Hopefully for the better.<span>&nbsp; <\/span>When the Visual Studio 10 beta becomes available I hope you&rsquo;ll give implicit line continuation a shot and let us know how it goes.<\/font><\/p>\n<p class=\"MsoNormal\"><font face=\"Calibri\" size=\"3\">-Tyler<\/font><\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Things are always changing.&nbsp; I was at the Washington State History Museum with my daughter a couple weeks ago.&nbsp; One of the exhibits features pictures of various sites that were taken many years ago.&nbsp; Then it contrasts them with contemporary pictures taken of the same locations.&nbsp; It was really interesting how much things changed and [&hellip;]<\/p>\n","protected":false},"author":260,"featured_media":8818,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[192,195],"tags":[158],"class_list":["post-2933","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-featured","category-visual-basic","tag-tyler-whitney"],"acf":[],"blog_post_summary":"<p>Things are always changing.&nbsp; I was at the Washington State History Museum with my daughter a couple weeks ago.&nbsp; One of the exhibits features pictures of various sites that were taken many years ago.&nbsp; Then it contrasts them with contemporary pictures taken of the same locations.&nbsp; It was really interesting how much things changed and [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/posts\/2933","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/users\/260"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/comments?post=2933"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/posts\/2933\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/media\/8818"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/media?parent=2933"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/categories?post=2933"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/tags?post=2933"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}