On Sunday, 9 June 2013 at 23:48:39 UTC, Ali Çehreli wrote:
On 06/09/2013 11:09 AM, deadalnix wrote:
> On Sunday, 9 June 2013 at 10:22:22 UTC, Jonathan M Davis
wrote:
>> I'd argue that it would make code harder to read, because it
hides where
>> the variables are coming from.
+1. A friend of mine is "still experimenting" with 'with' and I
hate reading his code. :)
with (new C()) {
i = 42; // is that a member of C?
j = 43; // how about that?
foo(); // and that?
bar(); // and that?
}
Thanks for obfuscating! :)
Ali
import std.stdio;
int foo()
{
writeln("foo");
return 0;
}
void main()
{
short i;
try switch (i)
{
writeln(i);
default:
writeln("default 1");
throw new Exception("");
}
catch(Exception e) do switch(foo())
{
default:
writeln("default 2");
} while(false);
finally if (i) switch(i) { writeln("do"); default: }
else {}
}
One bug with this funny stuff sharing common scoped statement is
import std.stdio;
bool foo()
{
writeln("foo");
return true;
}
void main()
{
short i;
switch(i) if (foo())
{
default:
}
else
foo();
}
It seems that if statement even doesn't reach backend.