lua-users home
lua-l archive

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


Again I am aware of this section of the FAQ.  Using the code that Peter
Shook posted, I have tried to add a tag method in the following way:

static int MyFunc(lua_State *L)
	{
	lua_error(L, "setglobal");
	return 0;
	}


int const_tag = lua_newtag(L);
lua_pushcfunction(L, MyFunc);
lua_settagmethod(L, const_tag, "setglobal");

This way I should be able to use my function to check the name of the
function and not allow it to be written to, but again my function is never
called.  I guess this is a basic tag method, but the documentation is a bit
sparse around this.  I cannot find 1 example of how to do it...

Chris Percival
Software Engineer
Interaxis Computing Ltd.
DDI:  +44 (0)1249 700072
http://www.interaxis.co.uk/

> -----Original Message-----
> From: owner-lua-l@tecgraf.puc-rio.br
> [mailto:owner-lua-l@tecgraf.puc-rio.br]On Behalf Of Luiz Henrique de
> Figueiredo
> Sent: 31 January 2002 11:52
> To: Multiple recipients of list
> Subject: Re: Read only variables
>
>
> >Is there any way to make that variable read only (or 'constant') in
> >the script, ie any attempt to change their value results in an error?
>
> See FAQ 3.3.
> --lhf