top | item 45870293

(no title)

cerved | 3 months ago

To anyone wondering, I believe it's cursed because the finally continue blocks hijacks the try return, so the for loop never returns

discuss

order

taneq|3 months ago

So the function returns, and then during its tidyup, the 'continue' basically comefrom()s the VM back into the loop? That is, indeed, cursed.

friendzis|3 months ago

I would not call this snippet particularly "cursed". There is no "aktshchually this happens, therefore this is activated" hidden magic going on. The try-catch-finally construct is doing exactly what it is designed and documented to do: finally block is executed regardless of the outcome within try. The purpose of finally block is to fire regardless of exceptionality in control flow.

Surprising at first? Maybe. Cursed? Wouldn't say so. It is merely unconventional use of the construct.

chii|3 months ago

see, if you only had GOTO's, this would be obvious what is going on!