On Mon, Apr 30, 2012 at 10:21:23AM +0200, bearophile wrote: > H. S. Teoh: > > >I think the correct solution here is to use alias. (If that doesn't > >work, then it should be made to work. It's a lot cleaner and doesn't > >introduce potentially nasty ambiguities into code, > > What ambiguities? [...]
When you have nested with's. Or when the object members shadow local variables in the parent scope. struct S { int x; } void main() { int x, y; S s; with(s) { x = 1; y = 2; } } Technically it's unambiguous which symbols are being referred to, but it makes the code hard to read because casual scanning will usually get it wrong. Plus, you're entirely at the mercy of the definition of S. If it's an imported object from an external library, for example, then when upstream makes changes to their struct/class there's a risk of introducing subtle errors into existing, correct code (by suddenly interpreting an identifier differently). This is never good. It gets worse with nested with's: when any object being with'd changes, you risk identifier collision. The worst thing is that this can happen just by upstream(s) changing object definitions, with no change in user code. T -- Long, long ago, the ancient Chinese invented a device that lets them see through walls. It was called the "window".