DIP 1002 (TryElseExpression) added to the queue
John Colvin via Digitalmars-d
digitalmars-d at puremagic.com
Thu Sep 29 00:49:30 PDT 2016
On Wednesday, 28 September 2016 at 23:44:19 UTC, Andrei
Alexandrescu wrote:
> On 9/28/16 7:40 PM, Andrei Alexandrescu wrote:
>>
>> // With scope
>> void assertNot(string s)
>> {
>> try { scope(success) assert(0, s);
>> decode(s,DecodeMode.STRICT); }
>> catch (DecodeException e) {}
>> }
>
> Sorry, this is not semantically equivalent. Replace with:
>
> // With scope
> void assertNot(string s)
> {
> try { decode(s,DecodeMode.STRICT); }
> catch (DecodeException e) { return; }
> assert(0, s);
> }
>
>
> Andrei
Aren't those the same, as assert won't ever throw a
DecodeException?
Simplest implementation:
try {
decode(s,DecodeMode.STRICT);
assert(0, s);
} catch (DecodeException e) {}
More information about the Digitalmars-d
mailing list