Reminds me of VBA, where the way to “return” a value in a function is to assign it to the function’s name
Sub f() 'returns 1
f = 1
End
I always thought this was insane, but it does make the semantics clear. Maybe not so insane after all
Sub f() 'returns 1
f = 1
End
I always thought this was insane, but it does make the semantics clear. Maybe not so insane after all
However, JavaScript actually started with rather quirky semantics for return: if any exit returned a value, all exits had to return a value, otherwise an error was thrown. Yet another effect of the nexus of control flow and assignment of a return value. (This got fixed with the introduction of the return object as workaround, which was, I think, in ECMA-Script 3.)