lua-users home
lua-l archive

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


Thanks for the feedback!

I am thinking of separating a special environment only for the public interface with the client.

-- put here all the variables the client can change
pub = {
    _name = ''
}

Writing to undefined variables raises an error (thanks Chris).

In protected code, you can write a kind of "reactive validation":

local _assert = L(assert)
local _type = L(type)
_protected_name =
_assert(EQ(_type(pub._name), "string"))
_html = "My name is " .. _protected_name

For instance, `_html` would not be public.

This thread convinced me that "global by default" is not the way for RSP. :)

--
Francisco Sant'Anna
http://www.lua.inf.puc-rio.br/~francisco/