No parenthesis for assert?
Peter Alexander
peter.alexander.au at gmail.com
Thu Jan 12 13:35:24 PST 2012
On 12/01/12 4:34 PM, Alex Rønne Petersen wrote:
> On 12-01-2012 16:57, Manfred Nowak wrote:
>> Alex Rønne Petersen wrote:
>>> Is there any reason parentheses are required
>> Yes.
>>
>>> for all other use cases, it would be a nice thing to have.
>> Maybe, but only when no `assert'-expression(!) is evaluated ever ...
>> Because making parenthesis optional for `assert' would introduce
>> ambiguities.
>>
>> -manfred
>
> Right, it would only make sense when it's used as a statement
> expression. In all other cases, it wouldn't work, of course.
>
> - Alex
assert can also have a message:
assert(x == 0, "What's going on!?");
This would look odd without parentheses.
assert x == 0, "What's going on!?";
Not to mention that it would be ambiguous with the comma operator:
assert (a, b); // is this the comma operator, or two arguments?
More information about the Digitalmars-d
mailing list