
Sept. 12, 2021
8:14 p.m.
12.09.21 21:36, Chris Angelico пише:
I wonder, could this be simplified a bit, on the assumption that a well-written assertion shouldn't have a problem with being executed twice? Instead of keeping all the subexpressions around (a run-time cost), keep the AST of the expression itself (a compile-time cost). Then, when the exception is about to be printed to the console, re-evaluate it and do the display.
Yes, it would simplify, but we cannot guarantee this (especially in tests). If we could, we would not need an assert.