What's the proper way to use std.getopt?

bauss jj_1337 at live.dk
Wed Dec 13 06:55:46 UTC 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.


More information about the Digitalmars-d-learn mailing list