On 2026-02-09 18:21, blogdron (BLOGDRON) wrote:
> "function x() return end" not equal "function x() return nil end"?
> This case is for all Lua versions.
Hello blogdron,
Lua functions are not crippled "functions" from C or FORTRAN.
They return sequence of values.
So "return nil, nil" is two values, "return nil" is one and "return"
is zero. You can even count this way. Somewhat similar to Church numerals.
Funny part is that parenthesis () around sequence always return
sequence with one element. So zero sequence becomes sequence with one
"nil":
Lua 5.5.0 Copyright (C) 1994-2025 Lua.org, PUC-Rio
> f = function() return end
> print(f())
> print((f()))
nil
-- Martin