Verbose checking of range category

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sat Dec 11 15:43:03 PST 2010


On 12/11/10 1:32 PM, Jonathan M Davis wrote:
> On Saturday 11 December 2010 11:06:45 Jesse Phillips wrote:
>> Andrei Alexandrescu Wrote:
>>> This program will generate a valid executable, but will also print
>>> during compilation:
>>>
>>> Type int is not a random access range because:
>>>     no empty property
>>>     no front property
>>>     no popFront method
>>>     no indexing
>>>     no slicing
>>>
>>> When a programmer has an odd issue with a range check, turning
>>> verboseness of checks could help.
>>>
>>> What do you think?
>>>
>>>
>>> Andrei
>>
>> I think it would be best if DMD would emit which constraint failed. Better
>> support for automatically say why would be good too. Basically I like
>> bearophile's suggestion to give them more structure. But until then, yes
>> do this. It should be everywhere, but ranges a big, and need them now!
>
> It would be great if dmd said which constraint failed, but since you're dealing
> with an arbitary boolean expression, in many cases, would not be particularly
> straightforward to say what failed, and I expect that it would be a _big_ change
> for the compiler.

Exactly. Oftentimes certain tests are supposed to not fail. All we can 
do is to be verbose and let the programmer see the last messages emitted 
prior to failure.

Andrei



More information about the Digitalmars-d mailing list