lua-users home
lua-l archive

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


The idea is great, it can speed up the running speed of the code, but this limits the freedom of the code and restricts the modification of variables in the running phase.

云风 Cloud Wu <cloudwu@gmail.com> 于2021年4月25日周日 上午10:56写道:
The type of constants in Lua can only be boolean, number, string now.
It looks good If it can support more types.

My suggestion is that if it assigns a global var to a const local var,
 the var is evaluated during the loading stage rather than running.

Idioms like :

local print <const> = print

function foobar()
   print "Hello World"
end

The local print can be a light C function constant. It can reduce the
memory footprint (fewer upvalues) and may faster. And it's more
friendly to the JIT or AOT compiler.











--
http://blog.codingnow.com