3 ms·
return x can be understood as ret = x; // assign to the implicit return variable return; // return ret to the caller If the return is cancelled by a
by edflsafoiewq 5y ago
return x can be understood as
ret = x; // assign to the implicit return variable
return; // return ret to the caller
If the return is cancelled by a finally, its basically just the case of assigning to the ret variable multiple times; the last assignment wins.
There are a few languages where functions have an actual ret variable you can explicitly use.
- jaffathecake 5y agoIt's more of a 'result' variable, because the result can be a return or a throw. If you throw, it clears the return, and vice versa. I had something like this in the article originally, but then you also need to say that `catch` also does `_result = undefined`, and it felt messy.