goto skips declaration of variable

nrgyzer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Aug 19 01:04:54 PDT 2014


On Monday, 18 August 2014 at 17:47:21 UTC, ketmar via 
Digitalmars-d-learn wrote:
> On Mon, 18 Aug 2014 13:51:12 +0000
> nrgyzer via Digitalmars-d-learn 
> <digitalmars-d-learn at puremagic.com>
> wrote:
>
>> When I try to compile this sample application I'm getting the 
>> following error:
>> 
>> sample.d(7): Error: goto skips declaration of variable 
>> sample.main.__ctmp1344 at sample.d(9)
> it's compiler bug i believe.
>
> but why do you need gotos at the first place? i'm not saying 
> that "you
> must avoid gotos at all costs!", but D has some nice features 
> like
> scope(exit), scope(success), scope(failure) and nested 
> functions, which
> can render gotos unnecessary in many cases (and make code 
> cleaner).

I know, gotos are having a negative connotation. Sure, I can also 
use nested functions, but in my opinion it results in dirty and 
complex code. It's totally overkilled compared to a simple if and 
goto-instruction. The same regards the scoping... it's simply to 
much overhead.


More information about the Digitalmars-d-learn mailing list