[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Is there a kernel patch for creating local variables programmatically?
- From: Tim Hill <drtimhill@...>
- Date: Sat, 18 May 2013 13:52:22 -0700
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.
The only thing I think would work is a bit of syntactic sugar. Something like:
local a, b, c from some_table
Which the compiler could re-write as:
local a, b, c = some_table.a, some_table.b, some_table.c
This is robust at both compile and run-time given Luas handling of undefined table items, but doesn't give you the "wildcard" you were suggesting.
On May 18, 2013, at 1:06 PM, Dirk Laurie <firstname.lastname@example.org> wrote:
> Often on this list voices have gone up proposing a language addition
> that would allow one to automate the following process:
> local concat,insert,remove,pack,sort,unpack=
> table.concat, table.insert, table.remove, table.pack,
> table.sort, table.unpack
> by saying Pythonically
> from table import *
> or whatever. Has anybody ever actually produced a kernel patch that
> implements something of the kind?