Trailing catch on function?

Manu via Digitalmars-d digitalmars-d at puremagic.com
Tue Nov 8 08:02:25 PST 2016


On 8 November 2016 at 09:37, Walter Bright via Digitalmars-d <
digitalmars-d at puremagic.com> wrote:

> On 11/6/2016 8:30 PM, Manu via Digitalmars-d wrote:
>
>> Hey people, I'm passing lots of D function pointers to C, and naturally,
>> the C
>> api expects the fp signatures are all nothrow.
>>
>> Which means, my D functions all look like this:
>>
>> void callback() nothrow
>> {
>> try
>> {
>> ...lots of code...
>> }
>> catch (Exception e)
>> {
>> ...log error or abort...
>> }
>> }
>>
>>
>> I'm generally annoyed by all the extra indentation.
>>
>
> void callback() nothrow
> {
>     scope (failure)
>     {
>         ...log error or abort...
>     }
>     ...lots of code...
> }
>

scope(failure) doesn't catch... how is that function nothrow?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20161109/bd3dafb7/attachment.html>


More information about the Digitalmars-d mailing list