Invariant and pre/post-conditions order

Steven Schveighoffer schveiguy at yahoo.com
Thu Jan 19 20:36:22 PST 2012


On Thu, 19 Jan 2012 23:24:59 -0500, Jonathan M Davis <jmdavisProg at gmx.com>  
wrote:

> On Thursday, January 19, 2012 23:19:02 Steven Schveighoffer wrote:
>> Imagine you have 1000 lines of code that call 50 or so
>> different methods on a class.  Any one of those calls in any one of  
>> those
>> methods could cause an invariant failure.  But only one method call can
>> cause a specific out condition failure, and the lines of code that call
>> that function might be significantly less than 1000 (maybe a handful).
>
> Won't you be able to see exactly which function failed in the stack  
> trace? Or
> does it not show up, because the invariant is checked _after_ the  
> function
> call? I would still think that the stack trace would make it fairly  
> clear even
> if that's the case.

If you get one (that is human decipherable).  This doesn't always happen.   
But like Walter and you said, the order is irrelevant to the execution of  
the program, why make the developer work harder than he has to?  It makes  
no sense to me *not* to change it.

-Steve


More information about the Digitalmars-d mailing list