goto :SOMEWHERE but please don’t do no harm

Exceptions are a modern way of getting back the complexity in code we lost when goto got banned from the code bases. You can do really useful stuff with exceptions.

fun allocate_resource()
  try 
    if (resource = allocate()) 
      throw ResourceAllocatedException()
    allocate_resource() 
  catch
    return resource

And don’t forget to 💤 between the recursive calls. Aint she a beauty?

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.