Does D have too many features?

H. S. Teoh hsteoh at quickfur.ath.cx
Mon Apr 30 09:42:30 PDT 2012


On Mon, Apr 30, 2012 at 05:47:59PM +0200, bearophile wrote:
> H. S. Teoh:
> 
> >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;
> >		}
> >	}
> 
> That code doesn't compile:
> 
> test.d(10): Error: with symbol test.S.x is shadowing local symbol
> test.main.x
[...]

Which means your code is at the mercy of the external library. Upstream
updates a class, and suddenly a whole bunch of code is unnecessarily
broken (if you had just used aliases instead, there would be no
problem).


T

-- 
It is of the new things that men tire --- of fashions and proposals and improvements and change. It is the old things that startle and intoxicate. It is the old things that are young. -- G.K. Chesterton


More information about the Digitalmars-d mailing list