lua-users home
lua-l archive

Re: A tricky way to determine Lua version

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


Am 21.05.2016 um 09:13 schrieb Sean Conner:
It was thus said that the Great Vadim A. Misbakh-Soloviov once stated:
 Mine relies upon strings still having a metatable.
But lacks luajit ;)
 Nah. If version is nil, it's LuaJIT.
 -spc (nil can't be a table key, see ... )
Thats all true. I still like Egors version because it is simple to use.
(without nil tests.) and the results can be changed eg.
function needs_setfenv()
 local f, t = function() return function() end end, {nil,
 [false] = true, --'5.1',
 [true] = false, --'5.2',
 [1/'-0'] = false, --'5.3',
 [1] = true, --'JIT'
 }
 return t[1] or t[1/0] or t[f()==f()];
end;
Ulrich

AltStyle によって変換されたページ (->オリジナル) /