On Wed, Aug 14, 2019 at 11:11 PM Soni "They/Them" L. wrote:
how about @self (returns the currently executing function object), @var
(returns the value of the variable being assigned to) and @table
(returns the table being currently constructed)?
(@table would be particularly useful for some DSLs. note that all of
these only affect the local lexical scope and don't work across
modules/function call boundaries.)
Oh, yes! Tables! I like the idea of referencing the table being constructed:
local vec = {x = get_x(), y = get_y(), len = (@.x^2 + @.y^2)^.5}
Positional references might also be useful:
local a, b = {name = "a", next = @2}, {name = "b", prev = @1}
What about more crazy things?
local function getxy() return x, y end
local len = (@2^2 + @3^2)^.5, getxy()
(x = @2 and y = @3 are returned by getxy() but not assigned to variables)
This might be good if it didn't look so Perl-ish :-)