lua-users home
lua-l archive

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


The reason I was asking this, was that I wanted to place watches on some Lua expressions from within C. As Lua functions may have environments other than the global environment, I will have to evaluate the expression within the correct environment (I wanted to just attach the current Lua function's environment to the C function that evaluates watches). But, by the looks, that evaluation cannot be done in C.

I will try, however, with a Lua watch evaluator that takes a Lua function as parameter (so that environments can be set properly).

Tai

-----Original Message-----
From: Roberto Ierusalimschy [mailto:roberto@inf.puc-rio.br]
Sent: Tuesday, October 07, 2003 5:06 AM
To: Lua list
Subject: Re: About function environments 


> >I am confused whether it is possible to associate the environment of
> >a Lua function with a C function. The manual seems to imply this is
> >not possible, but does not say so explicitly.
> [...]
> Is there any particular reason why this is not possible?

No strong reason. Mainly we felt that C functions do not need this
facility, because in C it is almost as easy to access any table field
as to access a global variable. Moreover, we did not want Lua to be able
to change the way a C function works (by changing its environment).

-- Roberto