lua-users home
lua-l archive

Re: Finding the version

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


Reuben Thomas wrote:
> 
> Is there a way of finding the version of Lua one is running? The obvious way
> to overcome the bug (if that's what it is) in tinsert that I just pointed
> out is to write a wrapper:
>[...]
> i.e. I could surround it with
> 
> if _VERSION < 4.1 then
> ...
> end
lua -e "print(_VERSION)"
--> Lua 4.0
So _VERSION is already there; it's set in the baselib.
> BTW, the tinsert bug appears to be present in 4.1alpha too.
IMHO the bug is the calling convetion on tinsert itself. The
statement
 tinsert(x, foo())
does completely different this when foo returns 1 or 2 results.
I think, these collection of functions would be better:
 tinsertat(table, pos, elements...) -- insert at pos
 tinsert(table, elements...) -- insert at 1
 tappend(table, elements...) -- append at -1
Ciao, ET.

AltStyle によって変換されたページ (->オリジナル) /