Goto skips declaration
programmer
programmer at mail.com
Wed Oct 31 04:59:06 UTC 2018
On Tuesday, 30 October 2018 at 06:37:22 UTC, Bauss wrote:
>
> D is not Javascript and has no concept of hoisting.
Neither is C.
--------------
#include <stdio.h>
int main()
{
// In C, depending on your warning settings, you might get
// an 'unreachable' code warning when you compile.
// D however, treats the code as an 'error', and won't
compile it...
// unless you add those extra braces.
// in my view, it should at most be a 'warning', not an
'error'.
// trust the programmer!
//{
goto Y;
int x;
printf("%d",x);
//}
Y:
puts("Hello");
}
--------------
More information about the Digitalmars-d
mailing list