On 02/26/2017 02:17 AM, Seb wrote:
On Sunday, 26 February 2017 at 06:34:07 UTC, Ali Çehreli wrote:
So, obviously, assert message generation is not lazy. This is a WAT!
for me but perhaps there is a good reason for it.
FWIW imho we shouldn't need to write such messages at all.
It shouldn't be to difficult to lower `assert (a BINOP b)` into sth. like:
(auto ref a, auto ref b) {
if (a BINOP b) return;
onAssertFailed!"BINOP"(a, b, __FILE__, __LINE__, __FUNCTION__,
__MODULE__);
} (e1, e2);
with onAssertFailed being a nice pretty-printer in the direction of:
assert([1,2,3] == [1,2,4]); // ERROR: ([1,2,3][2] is 3) != ([1,2,4][2]
is 4)
struct A { int x, y; }
auto a = A(1,2);
auto b = A(1,3);
assert(a == b); // ERROR: (a.y is 2) != (b.y is 3)
This idea is formally known as DIP83:
https://wiki.dlang.org/DIP83
Yea. Six years ago, assertPred was written for Phobos and rejected
because it was decided it was better for assert to just gain that
functionality built-in...which a full six years later, never happened.
Letting perfect be the enemy of the good, at its golden finest.