[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: Finding the version
- From: "Luiz Carlos Silveira" <luiz@...>
- Date: Mon, 13 Aug 2001 13:02:13 -0300
> 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:
>
> function tinsert(t, n, v)
> %tinsert(t, n, v)
> end
>
Be careful: to correctly implement tinsert in Lua using the C tinsert you must pass the correct number of parameters to the C
function, like in
function tinsert(t, n, v)
if (v) then
%tinsert(t, n, v)
else
%tinsert(t, n)
end
end
or the C tinsert will always think you are passing 3 parameters, even if the last is nil.
Lua 4.0 Copyright (C) 1994-2000 TeCGraf, PUC-Rio
> t = {}
> tinsert(t, 3)
> print(t[1])
3
> function tinsert(t, n, v) %tinsert(t, n, v) end
> t = {}
> tinsert(t, 3)
> print(t[1])
nil
> print(t[3])
nil
> t[3]=1
> tinsert(t, 3)
> print(t[3])
nil
> print(t[4])
nil
>