should postconditions be evaluated even if Exception is thrown?

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Thu Dec 3 09:32:17 PST 2009


Walter Bright wrote:
> Rory McGuire wrote:
>> I would think that if a method in a class throws then at least the 
>> class' invariant should be run? does it?
> 
> No.

Well you must do as you preach. Throwing a non-Error exception does not 
absolve a method from preserving the class invariant.

Again: throwing a subclass of Exception is part of the specification and 
can happen during the working of a system.


Andrei



More information about the Digitalmars-d mailing list