lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Because older versions of Lua had more strict scopes.
If you try to run this script in Lua 1.0 (Up to Lua 2.1) it will error:
"
$debug
local i = 123
repeat
    local I = 321
    print(i, I)
    i = i + 1
until i > 1000
"

Output:
"
nil
123
lua: unexpected type at conversion to number
        in statement begining at line 6 of file "benchmark.lua"
"

Since I test Lua VM and not trying to squeeze the performance I decided to preserve it as global for the entire benchmark. Am I wrong with this statement?

On Thu, Nov 12, 2020 at 2:39 AM Ranier Vilela <ranier.vf@gmail.com> wrote:
Em qua., 11 de nov. de 2020 às 20:24, Spar <developspartv@gmail.com> escreveu:
Almost every test uses functions that are not available from the beginning of Lua. Nucleotide uses metatables for example.
This benchmark test is aimed more to measure VM speed rather than RAM/features abilities.
I might use ack benchmark or stay with the current one.
Of course.

One question, why variable "i", is not declared as local?

regards,
Ranier Vilela