[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Numeric for loop: Changing control variable REALLY dangerous?
- From: bil til <biltil52@...>
- Date: Mon, 12 Dec 2022 10:19:16 +0100
Am Mo., 12. Dez. 2022 um 09:43 Uhr schrieb Rolf Kalbermatter
<rolf.kalbermatter@kalbermatter.nl>:
>
> But the Lua byte code generator could store the loop variable somewhere else than
> as a reference to the Lua stack, for instance directly in a reserved CPU register
> for performance reason ...
... sorry, but this is definitely NOT possible. Lua is delivered in
"multi-system" C code. It has NO knowledge about the CPU, on which Lua
will finally run.
So it is impossible that Lua would try to access any "reserved CPU registers".
It could only be, that on a "very special CPU" with a "very special
compiler" the C compiler would decide to do something like this.
But the C compiler would do this only, if the COMPLETE "Lua for loop"
would be a very "self-contained and protected" piece of code, not too
large. But this is definitely impossible... A Lua command inside a for
loop always has to check for userdata functions / meta functions /
coroutine yielding ... such a "Lua block" is never a "protected
super-small code piece" (super-small in respect of the number of CPU
commands...).