[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Lua 5.2 - emulation of old setfenv
- From: HyperHacker <hyperhacker@...>
- Date: Thu, 6 Jan 2011 00:21:21 -0700
On Thu, Jan 6, 2011 at 00:17, Dirk Laurie <email@example.com> wrote:
> On Thu, Jan 06, 2011 at 07:56:58AM +0200, Miles Bader wrote:
>> Lorenzo Donati <firstname.lastname@example.org> writes:
>> First step: what's the best way to detect one is running in 5.2?
>> I can do:
>> local lua_52 = string.match(_VERSION, " 5[.]2$")
>> but my impression is that such version-string matching is often thought
>> of as being not-so-good (e.g., the above will fail in 5.3 or 6.0, even
>> though they're likely to be more like 5.2 than 5.1).
> local lua_version = tonumber(string.match(_VERSION,'%d*%.%d*'))
> will allow the test
> if lua_version >= tonumber('5.2') then -- etc
I had been wondering why aside from _VERSION there isn't some variable
with the numeric version number for this purpose.
Sent from my toaster.