[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Why does MAXUPVALS apply to both Lua and C closures?
- From: shankusu2017 <shankusu2017@...>
- Date: Tue, 13 Jul 2021 12:42:53 +0800
However, why there are so many upvalues in your design, can you optimize the design? Or putthem into a table
PUC Lua 5.4 has a hard limit of 255 upvalues, both for Lua closures and
for C closures. The comment next to MAXUPVALS in lfunc.c says that this
is because the index of an upvalue must fit in an 8-bit virtual-machine
I understand why this would be the case for Lua closures. Many VM
instructions such as GETUPVAL refer to the upvalue using an 8 bit
However, I don't understand why this limit also applies to C closures,
the ones created via the C API with lua_pushcclosure. Is there some
place where the number of upvalues of a C closure must fit in 8 bits?
Or is this limit only to ensure that the limit is similar to the limit
for Lua closures?