[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Is there a kernel patch for creating local variables programmatically?
- From: Jay Carlson <nop@...>
- Date: Thu, 23 May 2013 10:36:47 -0400
On May 23, 2013, at 7:54 AM, Dirk Laurie wrote:
> 2013/5/18 Dirk Laurie <dirk.laurie@gmail.com>:
>> 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?
>
> After five days, the answer seems to be "No, because it is impossible."
I would not say it is impossible. I'd say that it has unexpected implications for how modules work: it adds a concept of compile-time dependencies.
There are a couple of possibilities for syntactic sugar with less power:
local (from table) concat,insert,remove,pack,sort,unpack
which is macro-transformed into what you wrote above. Another approach is a destructuring let:
local {concat, insert, remove, pack, sort, unpack} = table
But that looks like it should de-structure {1,2,3} rather than by keyword. In any case destructuring lets are often used for dealing with named, defaulting arguments, so there is a use outside import.
I think those should be pretty easy to implement in tokenf and LuaMacro.