lua-users home
lua-l archive

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


On Wed, Feb 14, 2018 at 2:46 PM, Sean Conner <sean@conman.org> wrote:
> It was thus said that the Great Alexander Schulz once stated:
>>
>> > Am 13.02.2018 um 22:45 schrieb Sean Conner <sean@conman.org>:
>> >
>> > If you stuff really is zero dependency functions, then what's the problem
>> > with specifying "lua >= 5.1, < 5.4" (where Lua 5.4 doesn't exist yet)?
>>
>> I know, I've thought a lot about that how to include different versions of the functions
>> for specific Lua Version. I haven’t found a good answer.
>> I am open for ideas.
>
>   I did a few spot checks, and from what I saw, there wasn't anything in the
> funtions I looked at that was specific to a particular Lua version.  But if
> it came down to it:
>
>         if _VERSION == "Lua 5.1" then
>           return function() -- Lua 5.1 version
>           end
>
>         elseif _VERSION == "Lua 5.2" then
>           return function() -- Lua 5.2 version
>           end
>
>         elseif _VERSION == "Lua 5.3" then
>           return function() -- Lua 5.3 version
>           end
>
>         else
>           error("Unsupported version of Lua")
>         end
>
>   -spc

That will work as long as there's no new syntax in newer versions that
make the older parser choke.

You could work around that by using loadstring([[ lua code here ]]) so
that it doesn't get parsed until runtime.

/s/ Adam