Lua 5.1 userdata fenv nil?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Lua 5.1 userdata fenv nil?

Marc Lepage
A userdata can have a table set as fenv. It has a default fenv.

Can I set the userdata fenv to nil? And later set it back to some table (empty, not the original default fenv)?

Would this have any weird effects?
Reply | Threaded
Open this post in threaded view
|

Re: Lua 5.1 userdata fenv nil?

Finn Wilcox
On 20/02/2013 20:48, Marc Lepage wrote:
> A userdata can have a table set as fenv. It has a default fenv.
>
> Can I set the userdata fenv to nil? And later set it back to some table
> (empty, not the original default fenv)?
>
> Would this have any weird effects?

You cannot set the fenv of a userdata to nil.  It must always be a
table.  But an empty table is fine.


Reply | Threaded
Open this post in threaded view
|

Re: Lua 5.1 userdata fenv nil?

Marc Lepage
OK, if that's true then I can at least use a singleton for the cases in which I want it to not be there. Thanks.


On Wed, Feb 20, 2013 at 4:32 PM, Finn Wilcox <[hidden email]> wrote:
On 20/02/2013 20:48, Marc Lepage wrote:
> A userdata can have a table set as fenv. It has a default fenv.
>
> Can I set the userdata fenv to nil? And later set it back to some table
> (empty, not the original default fenv)?
>
> Would this have any weird effects?

You cannot set the fenv of a userdata to nil.  It must always be a
table.  But an empty table is fine.