On Tuesday, 4 August 2015 at 23:06:44 UTC, John Colvin wrote:
I'm 90% on Walter's side here as he's right for the majority of common cases, but on the other hand there are plenty of situations where the boundary between code error and environment error get blurred.

Well, the principled difference is that asserts are program-specification-annotations and should not in any way affect execution within the code unit, and if it does it should happen as if it was detected by a hypothetical supervisor external to the program.

E.g. for a batch program terminate and have the calling context unwind any side-effects (as in a transaction), or for an interactive program to enter emergency mode, save state in a temporary file and try to recover after restart.

Asserts are reflecting system specifications (not code, or just applying to code).

If you want to take height for code errors you should use enforce or throw. It makes plenty of sense to assume that code have errors, and to recover from it, but using asserts does not assume that you have errors. It is just a way to add specification to the code for validation/documentation purposes.

I don't want those in release at all. I have way to many asserts for that.

So this goes much deeper than you and Walter suggest.

Reply via email to