Actually GW is right [...] Wether BlitzMAx does it or not is another story.
I didn't say he was wrong, specifically, just that Blitz wouldn't optimize them. Now, after having having looked at the assembly, I stand corrected. Blitz does optimize Final calls. Calling a final method (or a method of a final type?) is handled like a static function call.
Of course they do. There are a limited amount of registers (very little on intel CPUs) so that even if the compiler stores *some* local variables directly in registers there's always a point where it has to be stored on the stack (your saying 10, ok maybe). But the real point is that there is not just one function on the stack at one point. If your first function (with local variables stored in registers) is calling another function, where will it store these local variables while the second function is executing? Right, on the stack, so in the end the more local variables has the first function, the more it takes memory at one point.
Locals are only stored for as long as they are needed, so there usually aren't too many simultaneously for them not to fit in registers. The point you make about function calls is true, but that's not specific to Local variables: also intermediate values from expressions need to be stored. What I'm saying is, there's (usually) no need to minimize the number of Local variables per se. Stuffing everything into a large expression isn't going to make it any faster, as long as the algorithm is the same. On the other hand it will make reading the code a pain.
And actually usually functions do not work that way, they do store local variables on the stack (only they might load their values in registers *too* at the beginning for speed purpose).
That depends on the compiler, I guess, but I think a Local that's only needed in the next two lines will not be stored on the stack.