Derek Parnell wrote:
On Sun, 17 May 2009 19:33:35 -0500, Andrei Alexandrescu wrote:
I think "with" is a very dangerous feature due to the way it hides
symbols. It essentially makes the feeblest attempt at modular reasoning
utterly impossible:
int x, y;
with (whatever)
{
y += x;
++x;
}
I agree.
I guess the reason for using with() is to avoid typing repetitive stuff.
Would this work instead ...
int x, y;
with (p as "somevery.long.struct.or.class[17].name")
{
y += p.x;
++p.x;
}
You could as well use auto and a block without statement before it to
set the scope. But that'd look kind of ugly. A block without statement
looks like you forgot an if.
Here's another simple fix for with();
int x, y;
with (whatever)
{
.y += x; //.y references this is whatever.y
++x; //x references local scope
}