lua-users home
lua-l archive

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


On Sat, May 18, 2013 at 4:22 PM, Tim Hill <drtimhill@gmail.com> wrote:
> I'm not even sure if this would be possible?
>
> local variables are assigned to stack slots at compile time, so something like this would require the compiler to know the contents of a table at compile-time, not run-time, to determine the set of locals to create. Since tables are dynamic, this means the compiler would have to know, in advance, what the contents of a table was going to be at run time. Does not compute.

Tables could be given a `constant' attribute over their keys, either
by deduction, or in the case of what's favorable for tables holding
module entries, by an explicit token.

The concept wouldn't have to bask in more complexity than providing
means for the compiler to asses the number of keys for the purposes of
CT-"table globbing", which in turn is just a subset of pattern
matching.

Also, directly exposing tables to env-controlled programs is more
performant this way than with metamethods that check for "write
permissions".