DMD 1.027 and 2.011 releases

eao197 eao197 at intervale.ru
Wed Feb 27 02:13:49 PST 2008


On Wed, 27 Feb 2008 12:40:03 +0300, Ary Borenszweig <ary at esperanto.org.ar>  
wrote:

> eao197 escribió:
>>> eao197 wrote:
>> I'm affraid that you misunderstand my point. When you use a[i] or new  
>> in nothrow function you always known what could happen. But if you call  
>> virtual method from any object you can't predict its behaviour. Because  
>> the method implementation in some derived class could define contract  
>> for that method. And you may don't known about it.
>>  And becouse of this I think that 'nothrow' is a kind of function  
>> contract. And if a function defines such contract then it can't  
>> redefine it in derived classes.
>
> But contracts are predictable. Say B extends A, and A has a foo method.  
> If foo says nothrow, than if B overrides foo, it must also be nothrow  
> (this will be enforced by the compiler, I'm sure).

B.foo may looks like:

void foo() nothrow
   in { assert( <some condition> ); }
   out { assert( <some condition> ); }
   body { <some code without exception> }

Body of B.foo() doesn't throw exception but assert in pre/postcondition  
could do that. A call of B.foo could produce exception but B.foo is  
declared as 'nothrow' :(

-- 
Regards,
Yauheni Akhotnikau


More information about the Digitalmars-d-announce mailing list