foreach (x; a .. b) and foreach_reverse (x; a .. b) should be disallowed

grauzone none at example.net
Mon May 18 05:27:43 PDT 2009


Christopher Wright wrote:
> grauzone wrote:
>> Look at this for example:
>>  > writefln("%s", is(typeof(rtzx) == char));
>> This compiles even if rtzx doesn't exist. But you probably wanted to 
>> check the type of rtzx, not it if rtzx exists. If you mistyped rtzx, 
>> the compiler will never tell you.
> 
> You can do 'is(typeof(rtzx)) && is(typeof(rtzx) == char)', or wrap it in 
> a template.

The first is() in your expression is completely redundant, though. Not 
sure what you mean.

Anyway, my point was not about what's possible, but that it leads to not 
very robust code. Besides, you can't even tell what exactly went wrong 
inside the is(), because the compiler (of course) doesn't emit any error 
messages if that code isn't compileable.



More information about the Digitalmars-d mailing list