On 15/12/20 11:16 pm, Paul Sokolovsky wrote:
I would suggest us rising up in abstraction level a bit, and think not in terms of "intermediate variables" but in terms of "intermediate storage locations".
The fact that it's a *named* intermediate storage location is important, because it means the programmer can see it, and will expect it to hold a bound method. So the compiler can't optimise away the bound method creation in that case. Well, it could if it could prove that the intermediate value isn't used for anything else subsequently, but that seems like a very rare thing for anyone to do. Why bother naming it if you're only going to call it once and then throw it away? So the compiler only bothers with the most common case.
You're now just a step away from the "right answer". Will you make it?
I'll be interested to find out what you think the "right" answer is. Or what the actual question is, for that matter -- that's still not entirely clear. -- Greg