A better assert() [was: Re: std.unittests [updated] for review]
Jonathan M Davis
jmdavisProg at gmx.com
Fri Feb 4 04:40:55 PST 2011
On Friday 04 February 2011 04:30:42 bearophile wrote:
> Jonathan M Davis:
> > However, I don't see why there would be any problem with
> > assert(0) meaning halt. It's a normal assert in non-release mode and it
> > sticks around in release mode, becoming a halt instruction. I use it
> > that way all the time. I don't see any problem with it whatsoever.
>
> There was a recent discussion about this. The final consensus was that
> assert(0) to mean HALT is a small wart in the D language, but it's not
> worth fixing it, because it's a small enough defect. But if now assert()
> gets a significant facelift, then this little problem may be fixed along
> with the other two.
Well, aside from the fact that I don' t think that it's a wart at all, I would
point out that TDPL specifically points out that assert(false) is converted to a
halt instruction. So, given that it's not a serious problem, I really don't
think that it's reasonable to change it. At this point, for us to change
something that's in TDPL, it pretty much needs to need changing, and I really
don't think that assert(0) qualifies.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list