lua-users home
lua-l archive

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




On 21/05/16 04:42 AM, Sean Conner wrote:
It was thus said that the Great Ulrich Schmidt once stated:
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;
   Hmm ... okay, how about:

local version = ({Q="Lua 5.1",R="Lua 5.2",S="Lua 5.3"})[
         ("").dump(function() end):sub(5,5)] or "LuaJIT"

And you can change it just as easily:

local version = ({Q=true,R=false,S=false})[
         ("").dump(function() end):sub(5,5)] or true
I'm not sure if that does what you think it does... (false or true = true)

   -spc (Okay, so a few comments might be nice ... 8-)



--
Disclaimer: these emails may be made public at any given time, with or without reason. If you don't agree with this, DO NOT REPLY.