lua-users home
lua-l archive

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


1)
Function "require" with empty module name
   require("")
actually loads the module "init.lua" from your Lua modules forder.
I found it very handy: I put things-needed-in-every-script in "init.lua",
and all my scripts are usually started with
   require''
 
Of course, if you have hidden file ".lua", it will be loaded instead of "init.lua"
 
Strictly speaking, this useful feature should be considered as a "require" bug/quirk:
the statement require("") means user's intention to load module ".lua",
but another module "init.lua" is silently loaded instead when ".lua" is absent.
It acts as if this file "init,lua" in located in the folder with empty name.
But there is no folder with empty name on my disk :-)
 
 
2)
VARARG instruction is described as
   R(A), R(A+1), ..., R(A+B-2) = vararg
When B=1, there are no registers at the LHS,
so the instruction is actually "copy vararg into nothing".
It's funny that Lua sometimes generates this instruction with B=1.
For example, for this line of code:
   local x = 42, ...
(There is no need to optimize this, as all use cases are silly/erroneous)