lua-users home
lua-l archive

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

----- Original Message -----
From: Luiz Henrique de Figueiredo <>
To: Multiple recipients of list <>
Sent: Monday, January 31, 2000 12:48 PM
Subject: Re: (Q) How to protect C-functions from being redefined?

> >From  Mon Jan 31 08:35:03 2000
> >From: "Maciej Maczynski" <>
> >
> >I have C-function registered with lua_register.
> >How can I protect them from being re-defined in Lua code?
> >I've tried the piece of code from FAQ, but it seems to be working only
> >native Lua functions.
> Section 3.3 of the FAQ contains
> settagmethod(tag(protect),"setglobal",protect)
> This protects *all* Lua functions, because we are using "tag(protect)",
> "protect" is a Lua function.
> To protect a C function named "f", do
> settagmethod(tag(f),"setglobal",protect)
> but note that this protects *all* C functions because all C functions have
> same tag.
> If Lua allowed tags to be set for functions, then you could proctect only
> by simply setting a newtag for f and using this tag in settagmethod.
> However, you can use the more elaborated scheme described in FAQ 3.3.
> --lhf

Thanks a lot!
Protecting all C functions is what I need.