lua-users home
lua-l archive

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

> On 3 Jul 2019, at 08:10, Sean Conner <> wrote:
> It was thus said that the Great Egor Skriptunoff once stated:
>> On Wed, Jul 3, 2019 at 9:19 AM Sean Conner <> wrote:
>>>> Besides, it would be useful to have non-constant to-be-closed variables
>>>  So, what exactly should happen in this code?
>>>        local <toclose> f ="a")
>>>        local x = f
>>>        f ="b") -- should 'a' be closed?  or not because of x
>>>        f ="c") -- should 'b' be closed?
>> In your example only the last value in variable f would be evicted.
>  Is that because of 'x'?  Or because that's the end of the scope?

It sounds like it might be better to have __assign and __deassign meta-functions, rather than <toclose>:

  f =‘a’) — __assign called on result of‘a’)
  local x = f — implicit f.__assign()
  local y = x — implicit x.__assign()

  y = ’something else’ — implicit y.__deassign() followed by (’something else’).__assign()
end — implicit x.__deassign() and y.__deassign() because they are going out of scope.

Chris Smith <>