assert(condition[, message]) patch
Derek Parnell
derek at psych.ward
Wed May 31 22:57:17 PDT 2006
On Wed, 31 May 2006 21:38:04 -0700, Unknown W. Brackets wrote:
> Walter,
>
> My most common use for having this is simple...
Excellent reply and I'm now convinced too.
As a heretical aside, with the almost released new version of Build, you
can do something like the C-styled assert macro.
You can define a macro replacement pattern such as ...
regexp <:assert\s(.*)::(.*):> =
if (!($1)) {writefln(`%%s:%%s`, `$1`, `$2`); assert(0);}
and then write in your code ...
<:assert result != 0::Bad result:>
which will transform into ...
if (!(result != 0)) {writefln(`%s:%s`,
`result != 0`, `Bad result`); assert(0);}
--
Derek
(skype: derek.j.parnell)
Melbourne, Australia
"Down with mediocracy!"
1/06/2006 3:48:31 PM
More information about the Digitalmars-d
mailing list