lua-users home
lua-l archive

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


On Tue, Mar 27, 2018 at 12:58 PM, Eric Man <meric.au@gmail.com> wrote:
> Yes "strong"is too long - what I meant was your original proposal of using
> setmetatable and __mode - it morphed into "make every table a strong one" so
> I wanted to bring the discussion back to this; I think it's a good proposal
> and I haven't read any good technical arguments against it yet.
>

Let  `set_strong_mode` be a wrapper to set the metamethod to anything
we need to make it strong. Then consider the following code:

```
local tab = {}
local key = {}
tab[key] = true
set_strong_mode(tab)
tab[key] = nil
key = nil
```

Now, how I can delete the table content?

Yes you can suppose that when set back to "Normal" mode, the key
should be collected, But this means that the set of a metamethod field
should trigger a table iteration. I did not find yet a nice way to
solve this issue...