[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: [Suggestion] Passing upvalues to load()
- From: "Claire Lewis" <claire_lewis@...>
- Date: Wed, 7 Oct 2015 10:56:26 +1030
In Rio Lua, the order is as they appear. So if a global access appears
before any other upvalue access on a function, _ENV is the first upvalue.
How does order factor in, if the code refers to them by name? I think
I'm overlooking something.
local u2, u3, u4, u5
print(u2, u3, u4, u5) -- _ENV is the first upvalue, because "print" is
actually "_ENV.print" (or "_ENV['print']")
Unless I'm missing something, I don't think this is reliable, that's an
implementation detail, and could change any future version, even a patch
release of 5.3.
The Lua 5.3 manual states: "Upvalues have no particular order, as they are
active through the whole function. They are numbered in an arbitrary order."
I'd probably recommend finding a different way to achieve this for a public