Re: goto skips declaration of variable

2014-08-21 Thread nrgyzer via Digitalmars-d-learn
On Thursday, 21 August 2014 at 17:39:16 UTC, Ali Çehreli wrote: On 08/21/2014 04:12 AM, nrgyzer wrote: > I'm using the goto-command to exit my function > if an error (not necessarily an exception) occured. Sorry to repeat myself but if an exception occurs in code before the goto, the exit code

Re: goto skips declaration of variable

2014-08-21 Thread Ali Çehreli via Digitalmars-d-learn
On 08/21/2014 04:12 AM, nrgyzer wrote: > I'm using the goto-command to exit my function > if an error (not necessarily an exception) occured. Sorry to repeat myself but if an exception occurs in code before the goto, the exit code will not be executed. Of course, it may be that the function is

Re: goto skips declaration of variable

2014-08-21 Thread nrgyzer via Digitalmars-d-learn
On Tuesday, 19 August 2014 at 20:33:00 UTC, monarch_dodra wrote: On Monday, 18 August 2014 at 13:51:14 UTC, nrgyzer wrote: Hi all, I've the following code snipped: import std.bigint; void main(string[] args) { BigInt i = "12345"; if (args.length > 1) { g

Re: goto skips declaration of variable

2014-08-19 Thread monarch_dodra via Digitalmars-d-learn
On Monday, 18 August 2014 at 13:51:14 UTC, nrgyzer wrote: Hi all, I've the following code snipped: import std.bigint; void main(string[] args) { BigInt i = "12345"; if (args.length > 1) { goto Exit; } i = BigInt("67890"); Exit:

Re: goto skips declaration of variable

2014-08-19 Thread Ali Çehreli via Digitalmars-d-learn
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

Re: goto skips declaration of variable

2014-08-19 Thread bearophile via Digitalmars-d-learn
nrgyzer: 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. Often nested functions are less complex, more clean and simpler code compared to using gotos. I suggest to start using

Re: goto skips declaration of variable

2014-08-19 Thread ketmar via Digitalmars-d-learn
On Tue, 19 Aug 2014 08:04:54 + nrgyzer via Digitalmars-d-learn wrote: > goto-instruction. The same regards the scoping... it's simply to > much overhead. it's a matter of taste, i think. i myself find 'scope(exit)' excellent, 'cause i'm always keep forgeting to free some resources / restore

Re: goto skips declaration of variable

2014-08-19 Thread nrgyzer via Digitalmars-d-learn
On Monday, 18 August 2014 at 17:47:21 UTC, ketmar via Digitalmars-d-learn wrote: On Mon, 18 Aug 2014 13:51:12 + nrgyzer via Digitalmars-d-learn wrote: When I try to compile this sample application I'm getting the following error: sample.d(7): Error: goto skips declaration of variable

Re: goto skips declaration of variable

2014-08-18 Thread ketmar via Digitalmars-d-learn
On Mon, 18 Aug 2014 13:51:12 + nrgyzer via Digitalmars-d-learn 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

Re: goto skips declaration of variable

2014-08-18 Thread Ali Çehreli via Digitalmars-d-learn
On 08/18/2014 09:07 AM, ollie wrote: On Mon, 18 Aug 2014 13:51:12 +, nrgyzer 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) http://dlang.org/changelog.html

Re: goto skips declaration of variable

2014-08-18 Thread ollie via Digitalmars-d-learn
On Mon, 18 Aug 2014 13:51:12 +, nrgyzer 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) > http://dlang.org/changelog.html#disable_goto_skips_init F

Re: goto skips declaration of variable

2014-08-18 Thread bearophile via Digitalmars-d-learn
It looks like a compiler bug https://issues.dlang.org/show_bug.cgi?id=13321 Bye, bearophile

Re: goto skips declaration of variable

2014-08-18 Thread bearophile via Digitalmars-d-learn
nrgyzer: import std.bigint; void main(string[] args) { BigInt i = "12345"; if (args.length > 1) { goto Exit; } i = BigInt("67890"); Exit: return; } When I try to compile this sample application I'm getting the foll