December 13, 2017
On Tuesday, 12 December 2017 at 18:34:26 UTC, Mike Wey wrote:
> On 12-12-17 00:35, Seb wrote:
>> D style would be to use sth. like this (instead of try/catch):
>> 
>> ```
>> scope(failure) {
>>    e.msg.writeln;
>>    1.exit;
>> }
>> ```
>
> I might have missed something, but where is `e` defined in this case?

I was thinking the same and can't find anything in the documentation that states you can retrieve the exception that caused the failure by an "e" variable.

All I could find is that in case you need to use the exception you'd have to do a try/catch.

So ultimately that code wouldn't work, according to the language specs.

I haven't tested it, so I don't know if it's some hidden feature, but if it is, then I'm against it.
December 13, 2017
On Wednesday, December 13, 2017 06:55:46 bauss via Digitalmars-d-learn wrote:
> On Tuesday, 12 December 2017 at 18:34:26 UTC, Mike Wey wrote:
> > On 12-12-17 00:35, Seb wrote:
> >> D style would be to use sth. like this (instead of try/catch):
> >>
> >> ```
> >> scope(failure) {
> >>
> >>    e.msg.writeln;
> >>    1.exit;
> >>
> >> }
> >> ```
> >
> > I might have missed something, but where is `e` defined in this case?
>
> I was thinking the same and can't find anything in the documentation that states you can retrieve the exception that caused the failure by an "e" variable.
>
> All I could find is that in case you need to use the exception you'd have to do a try/catch.
>
> So ultimately that code wouldn't work, according to the language specs.
>
> I haven't tested it, so I don't know if it's some hidden feature, but if it is, then I'm against it.

If it works, it's a bug related to code lowering (since scope statements are always lowered to try-catch-finally blocks). You're not supposed to have access to the exception in a scope statement.

- Jonathan M Davis

December 13, 2017
On Wednesday, 13 December 2017 at 07:37:17 UTC, Jonathan M Davis wrote:
> On Wednesday, December 13, 2017 06:55:46 bauss via Digitalmars-d-learn wrote:
>> [...]
>
> If it works, it's a bug related to code lowering (since scope statements are always lowered to try-catch-finally blocks). You're not supposed to have access to the exception in a scope statement.
>
> - Jonathan M Davis

Yeah that's what I thought.

Just tested and it doesn't allow you to.
1 2
Next ›   Last »