[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Lua 5.2 - emulation of old setfenv
- From: Miles Bader <miles@...>
- Date: Thu, 06 Jan 2011 14:56:58 +0900
Lorenzo Donati <firstname.lastname@example.org> writes:
> By the way, wouldn't it be good to ease the transition to 5.2 to create
> a place (lua.org? wiki?) where useful "compatibility" snippets/tricks
> like that could be found easily?
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). A better way might
be to detect the presence of a function that's in 5.2 but not 5.1 (but
hopefully one that's likely to remain even in future versions)?
[I'm probably not going to move to 5.2 quickly, just because I'm too
addicted to luajit, but still, it'd be nice to try and be portable to
all commonly used versions.]
Logic, n. The art of thinking and reasoning in strict accordance with the
limitations and incapacities of the human misunderstanding.