guard clause style static if

Jonathan M Davis newsgroup.d at jmdavisprog.com
Tue Jul 10 12:10:27 UTC 2018


On Tuesday, 10 July 2018 05:38:33 MDT kdevel via Digitalmars-d-learn wrote:
> I would like to suggest an extension of the language by
> introducing
>
>      static return Expression_opt;
>
> which shall have the effect of a return plus that the remaining
> lines in the current block are treated as if they were enclosed
> in an else block.

Well, you can propose it, but it really doesn't fit with how static if
works. static if doesn't have anything to do with control flow, whereas what
you're proposing here would, which would arguably make it that much more
confusing. I confess that I don't understand what the problem is with simply
adding an else block. It's simple, and it works right now without any
language changes.

- Jonathan M Davis





More information about the Digitalmars-d-learn mailing list