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?