For normal closures there is no way to fix this problem. We can only have the closure return to it’s caller, which in this case is the function times we added to Int.
In many languages with macros, we would construct syntax by directly working with the syntax tree created by the compiler. This is can get fairly advanced and isn’t very easy to read.
As we see in this example we could do a lot of nice things if we just had something which “looks like a closure but unwinds the stack like an exception”
I would really like to see something like this in Swift.
Stay up-to-date by subscribing to the Comments RSS Feed for this post.