Lutger wrote: > Jonathan M Davis wrote: > >> Lutger wrote: >> >>> >>> True, it only adds AssertError and that could be replaced with regular >>> asserts. >>> >>> Thanks. >> >> ??? Regular asserts? When asserts in D fail, they throw an exception of >> type AssertError. So, unless you're talking about explicitly throwing an >> AssertError yourself (which seems rather silly to me), I don't know what >> you could mean by the difference of having an AssertError get thrown from >> having a "regular" assert. >> >> - Jonathan M Davis > > I wasn't clear, this is what I meant with 'regular' asserts: > > void foo() > { > assert(precondition); > } > > instead of: > > void foo() > in > { > assert(precondition); > } > body > { > }
Ah, okay. Normally, both would be there in debug mode and neither would be there in release mode, though I believe that if you were to use the unittest flag in release mode, you'd get the asserts inside functions but not the ones in contracts. So, there _could_ be a difference, but in most cases, there wouldn't be. Naturally, if you really want to make it so that calling a particular function throws an exception, you're going to want to throw that exception yourself rather than using an assertion. - Jonathan M Davis