DIP 1002 (TryElseExpression) added to the queue
Andrei Alexandrescu via Digitalmars-d
digitalmars-d at puremagic.com
Thu Sep 29 04:48:51 PDT 2016
On 09/29/2016 03:49 AM, John Colvin wrote:
> 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) {}
Correct, thanks. -- Andrei
More information about the Digitalmars-d
mailing list