`finally` is redundant?

Jonathan M Davis via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Nov 21 16:10:45 PST 2015


On Saturday, November 21, 2015 11:15:22 Shriramana Sharma via Digitalmars-d-learn wrote:
> The page http://dlang.org/exception-safe.html says:
>
> "It's try-finally that becomes redundant."
>
> IIUC this is because we have scope(exit).
>
> Does this mean that `finally` should eventually be removed from the
> language?

finally isn't going anywhere, and there are cases where it still makes
sense. Also, when scope(exit) is used, the code is "lowered" to be use
finally (i.e. the code is transformed by the compiler from one construct to
another). So, currently, the only reason that scope(exit) even works is
because we have finally. Getting rid of finally would mean reimplementing
scope(exit) differently, and there really isn't any reason to get rid of it
anyway. Just because scope(exit) is usually better doesn't mean that finally
is never appropriate.

- Jonathan M Davis



More information about the Digitalmars-d-learn mailing list