proposal: should assert behave like static assert if its possible?
dennis luehring
dl.soluz at gmx.net
Mon Jan 21 00:04:56 PST 2008
Walter Bright schrieb:
> torhu wrote:
>> dennis luehring wrote:
>>> my question for walter is:
>>>
>>> can't assert behave like static assert if the value/condition is
>>> available compiletime
>>>
>>> for example:
>>>
>>> int x = byte_bit_to_int( 7, 9 ); // an static assert could do the check
>>>
>>> int x = byte_bit_to_int( 7, random(8) ); // the normal assert is needed
>>
>> The problem is that sometimes you write things like assert(0), and
>> need it to trigger at runtime, not compile time. So I think there
>> would still be a way to do that.
>
> You're right (it's runtime flow of control sensitive), and that's why it
> doesn't trigger at compile time.
i know why it doesn't trigger at compiletime
my question is - why can't you make it trigger at compiletime
if the condition is false at compiletime
we (just) need an replacement for assert(false) or assert(0) constructs,
right?
why don't replace this assert(false) constructs with just assert()
ciao dennis
More information about the Digitalmars-d
mailing list