4 ms·
Think about a recursive function whose implementation is changed while it is running. The replacement might have an entirely different algorithm. Which versio
by Beltiras 9y ago
Think about a recursive function whose implementation is changed while it is running. The replacement might have an entirely different algorithm. Which version finishes the stack call?
- chrisseaton 9y agoThe version that was originally activated. I think that's the case in every single parallel implementation of a programming language ever. I can't imagine it working any other way. When you redefine a method in any language I'm aware of you just change which method the name points to. You don't modify the original method.
- Beltiras 9y agoSo a function: def fun(*args): if not args: return 0 return fun(*(args[1:])) would be call-by-address after the first invocation? It could be lookup-by-name by way of code.
- chrisseaton 9y agoThe naive implementation, and the semantic model, is always lookup-by-name on every invocation. In practice we apply speculative optimisations including inline caching and guard removal with remote dynamic deoptimisation via safe points to make it a direct call instead.