lua-users home
lua-l archive

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

Lorenzo Donati <> writes:
> By the way, wouldn't it be good to ease the transition to 5.2 to create
> a place ( 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.