DMD 1.027 and 2.011 releases
Russell Lewis
webmaster at villagersonline.com
Mon Feb 25 13:38:06 PST 2008
The example would be (reasonably) compilable, without whole-program
knowledege, if foo() had an in{} condition which asserted that the index
was valid.
It would be possible (though not trivial) for the compiler to say "ah,
provided that the caller follows the in{} contract, this function cannot
throw an exception."
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.
More information about the Digitalmars-d-announce
mailing list