Impressed

Ali Çehreli acehreli at yahoo.com
Thu Jul 26 20:32:53 PDT 2012


On 07/26/2012 06:58 PM, Stuart wrote:
 > On Friday, 27 July 2012 at 00:23:54 UTC, Ali Çehreli wrote:

 > Well, kinda. "Goto case" and such are one thing, but allowing the
 > arbitrary use of goto for jumping around from label to label.... I just
 > don't understand why the language even supports this.

Unlike C++, the language disallows unsafe jumping forward (or is it dmd 
that disallows it?). Hmmm... Maybe I am wrong... (?) I swear, the 
following code used to generate a compilation error:

     if (aCondition) {
         goto label;    // Jumps over s's constructor call
     }

     auto s = S(7);

label:

     s.foo();

The error used to say:

   "Error: cannot goto forward into different try block level."

The code is allowed by dmd 2.059.

The code is allowed for classes as well but of course there is a 
segmentation faault due to foo() on the null object. Strange...

 > Anyone using 'goto
 > label' in their code is doing it wrong. Period.

I agree.

Ali



More information about the Digitalmars-d mailing list