[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: _G equilence in Lua 4
- From: Fabricio de Alexandria <fabricio@...>
- Date: Thu, 22 Apr 2004 17:36:27 -0300 (BRT)
Thanks. I thought this was related to what I want. I've already had a look
at this in the manual but I just found the set/getglobal. I don't know if
I understood what this functions do but I think this is not what I'm
looking for. They get/set values of a global variable. I want to change a
function and introduce new instructions on it.
This is what I want to do. I have a function called test() and I want to
change it.
function test()
print 'test'
end
function change( f )
table = _G
local old_fn = table[f]
table[f] = function( ... )
print "function changed"
return (old_fn)(unpack( arg ))
end end
print 'before change'
test()
print 'after change'
change ('test')
test()
And I get this:
before change
test
after change
function changed
test
What could be the equivalent code in Lua 4?
Fabricio
On Thu, 22 Apr 2004, Jamie Webb wrote:
> On Thursday 22 April 2004 14:36, Fabricio de Alexandria wrote:
> > Hi everyone,
> >
> >
> > I was developing scripts in Lua 5 and now I have to make them work
with
> > Lua 4 version. I'm using _G variable and I don't know the equivalent
in
> > Lua 4.
>
> globals()
>
> -- Jamie Webb
>