title: How to simulate try-finally or try-except in languages that don't have them
body: <p>Is there <strong>any</strong> way to simulate a <code>try-finally</code> or <code>try-except</code> in a language that doesn't have them?</p>
  
  <p>If there's some random, unpredictable, exception happens i need to be sure some cleanup runs.</p>
  
  <p>i <em>could</em> try to be sure that no exception in thrown, that way i am sure my cleanup code always runs - but then i wouldn't need the <code>try-finally/except</code>.</p>
  
  <p>Right this moment i'm trying to create a <code>try-finally</code> in Lua; but i think any solution would work in other languages as well.</p>
  
  <p>Although, for the life of me, i cannot figure out how an exception can be handled without the plumbing provided by the language infrastructure.</p>
  
  <p>But never hurts to ask.</p>