"with" should be deprecated with extreme prejudice

Spacen Jasset spacenjasset at yahoo.co.uk
Mon May 18 03:06:46 PDT 2009


BCS wrote:
> Hello Andrei,
> 
>> Robert Fraser wrote:
>>
>>> This. Just issue an error/warning if something in the with shadows
>>> something outside. That way, if the struct/class/template/whatever
>>> changes, affected code will be notified.
>>>
>> No warning, error!
>>
> 
> warning if it exist, error if used?
> 
> 

It probably should be an error. Then though, you have the unfortunate 
thing whereby adding something to say struct X will shadow and generate 
a compile error, which you can only fix by:

a) Not using with
b) rename identifier in your sturct
c) rename local variable


I seem to remember some language (I think it's VB) supporting with that 
required a "." prefix in front of with enclosures. Like so:

auto a = 0;
with (foo)
{
	a = 0;
	.a = 1;
}


This is a bit dangerous too though, in terms of typos.







More information about the Digitalmars-d mailing list