assert(false) in release == splinter in eye
Jonathan M Davis
jmdavisProg at gmx.com
Tue Oct 12 13:57:01 PDT 2010
On Tuesday, October 12, 2010 13:40:32 Andrei Alexandrescu wrote:
> On 10/12/10 13:58 CDT, Christopher Bergqvist wrote:
> > On Tue, Oct 12, 2010 at 2:37 AM, Andrei Alexandrescu
> > <SeeWebsiteForEmail at erdani.org
> >
> > <mailto:SeeWebsiteForEmail at erdani.org>> wrote:
> > assert(false) could be in an ideal world replaced by an intrinsic
> > called e.g. halt() that looks and feels like a regular function but
> > is recognized by the compiler. No new keyword would be needed. But I
> > don't think that would mark a significant improvement in the
> > language.
> >
> > Would it be possible to change the compiler to only treat
> > "assert(false);" specially, avoiding treating "enum a = 0; assert(a);"
> > or more complex constructs that way?
>
> Question is when to stop. assert(0), assert(false), assert(1 == 0)...
>
> Andrei
If we were to make that change, I'd say to make it simple and just use assert(0)
and assert(false), but it's certainly a valid point. Personally, I don't think
that it's an issue because it's really only going to happpen with compile-time
constants which wouldn't normally be in an assert statement anyway.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list