lua-users home
lua-l archive

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



François Perrad <francois.perrad <at> gadz.org> writes:

> The keyword 'final' is a specialization of the keyword 'local'.
> The goal is the defensive programming.

I'd like this very much and second this proposal.

> Only the parser is modified and produces new errors.
> The VM is not modified (The goal is not the performance optimization).

I believe, later on we could change this to constant propagation and thus get some optimizations (still without changing the VM!)

Think of something like this

final DEBUG = true

function somefunc(somearg)
    if DEBUG then
        print("somefunc(",somearg,")")
    end
    local result=do_something(somearg)
    if DEBUG then
        print("do_something(",somearg,")=",result)
    end
    return result
end

A smart compiler could eliminate the debug code, when DEBUG is set to false