lua-users home
lua-l archive

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

On Tue, 28 Sep 2010 11:24:11 +0300, Nilson <> wrote:

I suppose it will be at least 25 times faster with no additional
memory allocation.

You have to account for the overhead it will cause for all code
that doesn't use your const values.

The implementation of selective constants in tables using metamethods
requires LUA's ifs (much more time) or a table of hashed constants
(much more space and more time).

I can't imagine it being 25 times
faster than something like the following simple metatable based
read only object (just a sketch, this is not a tested code):

local t = { ... } --
local read_only = setmetatable({}, { __index = t, __newindex = bark_fn, __metatable = bark_fn })

Login = const(Login) -- Avoids ManInTheMiddle internal attack

As HyperHacker very well explained in another reply,
this does not really prevent internal attack.

Are these commands complex? Imagine doing the same thing with metatables.

Actually, I cannot imagine doing it in Lua at all. The WoW people
tried to create some form of access policy. And while it works, it's
neither simple, nor generic.

See this for a well thought-out example of
language-level access control (this one is capability based):