DMD 1.027 and 2.011 releases

Graham St Jack graham.stjack at internode.on.net
Mon Feb 25 02:09:52 PST 2008


On Mon, 25 Feb 2008 01:44:15 -0800, Walter Bright wrote:

> Ary Borenszweig wrote:
>> Does this mean this will not compile:
>> 
>> int foo(int[] someArray, int someIndex) nothrow {
>>     return someArray[someIndex];
>> }
>> 
>> but this will:
>> 
>> int foo(int[] someArray, int someIndex) nothrow {
>>     if (someIndex < someArray.length) {
>>         return someArray[someIndex];
>>     } else {
>>         return -1;
>>     }
>> }
> 
> I don't know yet. But the idea is to do static checking of what can
> throw.

It will be a good trick if you can pull it off. I don't see how it can be 
done without examining the source code of all the called functions, 
leaving us back where we started with throw specs.

The C++ approach of a runtime check isn't perfect, but at least it can be 
done, and provides a more definite form of documentation than comments.

If the static checks aren't done well enough and runtime checks aren't 
done at all, I would prefer to rely on comments.


More information about the Digitalmars-d-announce mailing list