www.digitalmars.com         C & C++   DMDScript  

D - assert syntax

reply "Sean L. Palmer" <seanpalmer earthlink.net> writes:
just wondering if assert could be made syntactically more like return
(doesn't need parenthesis, but it's ok if they're present):

void foo(int x)
{
   assert x < 5;
}
Jun 15 2002
parent reply "Walter" <walter digitalmars.com> writes:
"Sean L. Palmer" <seanpalmer earthlink.net> wrote in message
news:aef8gf$2lbm$1 digitaldaemon.com...
 just wondering if assert could be made syntactically more like return
 (doesn't need parenthesis, but it's ok if they're present):

 void foo(int x)
 {
    assert x < 5;
 }
Assert is implemented as an expression, not a statement, so leaving off the () would cause some parsing ambiguities.
Jun 15 2002
parent reply Pavel Minayev <evilone omen.ru> writes:
On Sat, 15 Jun 2002 23:07:50 -0700 "Walter" <walter digitalmars.com> wrote:

 Assert is implemented as an expression, not a statement, so leaving off the
 () would cause some parsing ambiguities.
And what's it type? void?
Jun 16 2002
parent "Walter" <walter digitalmars.com> writes:
"Pavel Minayev" <evilone omen.ru> wrote in message
news:CFN374234893359722 news.digitalmars.com...
 On Sat, 15 Jun 2002 23:07:50 -0700 "Walter" <walter digitalmars.com>
wrote:
 Assert is implemented as an expression, not a statement, so leaving off
the
 () would cause some parsing ambiguities.
And what's it type? void?
Yes. (You obviously think like I do <g>.)
Jun 16 2002