digitalmars.D - Re: std.unittests for (final?) review
- Jim <bitcirkel yahoo.com> Jan 08 2011
- Jonathan M Davis <jmdavisProg gmx.com> Jan 08 2011
- =?UTF-8?B?IkrDqXLDtG1lIE0uIEJlcmdlciI=?= <jeberger free.fr> Jan 09 2011
Jim <bitcirkel yahoo.com> writes:
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.
Jan 08 2011
Jonathan M Davis <jmdavisProg gmx.com> writes:
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
Jan 08 2011
=?UTF-8?B?IkrDqXLDtG1lIE0uIEJlcmdlciI=?= <jeberger free.fr> writes:
Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Jim wrote:I have to agree. =20 assert(1 + 1 < 3); =20 will always be easier to read than any: =20 assertPred!"a < b"(1 + 1, 3); =20 Why not just keep it simple and straight forward? Anything expressed in=
True, but on the other hand: Assertion failed! will always be less informative than any: Assertion failed: 3 < 2! It all depends on whether your priority is code or message readability. I would tend to give priority to the error message. Jerome --=20 mailto:jeberger free.fr http://jeberger.free.fr Jabber: jeberger jabber.fr
Jan 09 2011