[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: CONSTANTS patch - LKBIT
- From: Nilson <nilson.brazil@...>
- Date: Tue, 28 Sep 2010 05:24:11 -0300
On Tue, Sep 28, 2010 at 4:45 AM, HyperHacker <hyperhacker@gmail.com> wrote:
> While disallowing changes of individual table values is an interesting
> idea, it doesn't look like this offers a whole lot of advantage over
> what we can do with metatables already. The only major advantage I see is being faster,
I suppose it will be at least 25 times faster with no additional
memory allocation.
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).
Of course, metamethods are much more versatile. Lua is great.
The CONST patch (new name here) is not a replacement of metamethods.
> and this is at the cost of some added complexity.
MY_CONSTANT = const(20)
Login = const(Login) -- Avoids ManInTheMiddle internal attack
Are these commands complex? Imagine doing the same thing with metatables.
> What you call a constant here isn't the same as what many languages
> call a constant. Your idea is to be able to set a read-only bit on
> (...)
Quoting myself:
On Tue, Sep 28, 2010 at 2:29 AM, Juris Kalnins <juris@mt.lv> wrote:
> What exactly are the semantics of the functions that you propose?
When a value stored inside a field is locked, the value of the field
cannot be changed, what ***simulates*** a constant behavior.
> It would be nice to have constants in Lua, and your proposed feature
> is interesting, but they are two different things.
>
I agree, but I think it could be a "good enough" simulation.
--
Nilson