std.unittests for (final?) review
Jonathan M Davis
jmdavisProg at gmx.com
Sat Jan 8 18:13:17 PST 2011
On Saturday 08 January 2011 15:21:44 Jim wrote:
> I have to agree.
>
> assert(1 + 1 < 3);
>
> will always be easier to read than any:
>
> assertPred!"a < b"(1 + 1, 3);
>
> Why not just keep it simple and straight forward? Anything expressed in the
> latter form can be expressed in the former.
Well, honestly, after seeing enough stuff like the second example, I have no
trouble reading it pretty much as quickly as the first one - especially with more
complex expressions - but I can see why some would consider that an issue.
However, my take on this is that the built-in assert cannot currently give us
the kind of error messages that assertPred!() will. So, regardless of whether
the built-in assert is improved later, if we want that kind of functionality
now, then we need to have something like assertPred!().
Now, it would be extremely cool if the built in assert were able to give us
error messages similar to what assertPred!() will do, so it could very well be
valuable to add that later, but it's an implementation detail (similar to
improving error messages), it's not necessarily going to be very easy to do, and
assertPred!() will have already given us the necessary functionality, so I
wouldn't expect such a change to be particularly high priority. It would
probably have to be done by someone other than Walter who had the time and
interest in doing it, since Walter has plenty of more important things an his
plate.
So, assert my eventually be that cool, but it isn't now, and it may never be, so
we create assertPred!() now, and then we have a solution. If assert eventually
_is_ that cool, then it'll be an option to use that instead of assertPred!() for
getting better error messages. But for now, it isn't an option.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list