2

Which programming language first came up with the finally block?

I ask purely out of curiosity.

It is a very useful piece of syntactic sugar, and whoever first created it surely has a very impressive grasp of solutions to programming problems.

(Note: it is deceptively difficult to find an answer to this question...)

asked Oct 1, 2014 at 17:55
8
  • 3
    Why would you call it syntactic sugar? Commented Oct 1, 2014 at 18:05
  • 2
    Related reading: Why is there no 'finally' construct in C++? Commented Oct 1, 2014 at 18:06
  • @PieterB the block helps avoid duplicate code (copy pasting the statement into try and each catch block). A try-finally block helps avoid a try-catch-rethrow block which is ugly, harder to understand, and defeats the purpose of such blocks. To quote another source, everything can be accomplished without the finally block, but everything also can be accomplished on a Turing Machine. That doesn't make it good form, though. Commented Oct 1, 2014 at 18:13
  • 1
    @PieterB because you can replace try{}finally{...} with try{}catch(e){...;throw e;} Commented Oct 1, 2014 at 18:39
  • 5
    @ratchetfreak It's not that simple. ... is also executed when the try block is left via any other means: continue, break, return, and whatever other control flow statements the language offers. Of course there is still a way to replace the finally with other constructs but I think it's far beyond the threshold for syntactic sugar. Commented Oct 1, 2014 at 19:03

1 Answer 1

10
answered Oct 1, 2014 at 18:03

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.