[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Preserving globals between chunks
- From: Thomas Lauer <thomas.lauer@...>
- Date: Thu, 10 Jul 2008 09:47:38 +0100
"Paul Moore" <p.f.moore@gmail.com> wrote:
Hey Paul, you're the 'p.f.moore' who's posting over on the 4nt list as
well? If so, it seems you're into writing another plugin for 4nt;-)
> I'm trying to write some C code that executes user-supplied chunks. I
> want to use the same environment between chunks, so that (for example)
>
> my_execute_chunk(L, "function f() print(\"Hello, world\") end")
> my_execute_chunk(L, "f()")
>
> should print "Hello, world".
>
> At the moment, it doesn't, because each chunk is evaluated with a
> local scope, so that the f defined in the first chunk is lost, and f
> in the second chunk is nil.
You could have a look at my lua4nt plugin (source code is in the public
domain): http://thomaslauer.com/download/lua4nt02.zip
I've not seen your code so I am not sure what I am doing differently but
my plugin definitely keeps state between invocations. The code is
neither overly long nor especially complicated, so it shouldn't be
difficult to locate the difference.
--
cheers thomasl
web: http://thomaslauer.com/start