goto skips declaration of variable

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Aug 19 10:17:07 PDT 2014


On 08/19/2014 01:04 AM, nrgyzer wrote:

 > On Monday, 18 August 2014 at 17:47:21 UTC, ketmar via

 >> 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.

However, goto is not a substitute for scope(exit) and friends or similar 
D features because goto may not be executed if an exception is thrown.

Ali



More information about the Digitalmars-d-learn mailing list