Do you think if statement as expression would be nice to have in D?

kdevel kdevel at vogtner.de
Sun Jun 5 15:18:16 UTC 2022


On Sunday, 5 June 2022 at 00:48:04 UTC, Walter Bright wrote:
> On 6/4/2022 9:15 AM, Nick Treleaven wrote:
>> Just like `throw` is an expression in D now. It's type is 
>> noreturn, which implicitly converts to any type.
>
> Which is causing unexpected problems :-/

BTW: I would have expected try to become an expression such that 
one can write

    int v = try foo (...);
    catch (...) {...}
    ...

as in Perl

    my $v = eval { foo (...); };
    if ($@) ...


More information about the Digitalmars-d mailing list