[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Non-lexical (lexical) scoping
- From: "Soni \"They/Them\" L." <fakedme@...>
- Date: Tue, 20 Mar 2018 02:09:24 -0300
On 2018-03-20 01:57 AM, Dirk Laurie wrote:
2018-03-20 0:38 GMT+02:00 Soni "They/Them" L. <fakedme@gmail.com>:
Let's talk about non-lexical lexical scopings. That is, the ability to undefine variables.
,,,
forget a
...
local a, a, a = 1, 2, 3
This assumes something about implementation of multiple assignment
that Lua does not promise.
...
Those are 3 different locals.
local a, a, a = 1, 2, 3
*is*
local a = 1
local a = 2
local a = 3
(however, the order in which they are assigned is undefined [1])
But, this is different from
a, a, a = 1, 2, 3
Which is undefined, and could be any of:
a = 1
a = 2
a = 3
a = 3
a = 2
a = 1
a = 1
a = 3
a = 2
etc, you get the idea.
[1] - Using non-lexical scoping, local a, a, a = 1, 2, 3 could be
expanded to any of:
local a
local a
local a
do
forget a
forget a
a = 1
end
do
forget a
a = 2
end
do
a = 3
end
-- or
local a
local a
local a
do
a = 3
end
do
forget a
a = 2
end
do
forget a
forget a
a = 1
end
-- etc
They are still 3 locals, declared in order, with the 3 values also
declared in order.
I think this sounds neat. What do you think?
`forget a` looks evocative [1]. But `pop(a)` is the more usual word
for this sort of thing.
[1] https://xkcd.com/379/
--
Disclaimer: these emails may be made public at any given time, with or without reason. If you don't agree with this, DO NOT REPLY.