lua-users home
lua-l archive

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


Warning: I'm just rambling here!

2018-03-13 16:43 GMT-03:00 Roberto Ierusalimschy <roberto@inf.puc-rio.br>:
> for k,v in pairs(t) do print(k, v) end
1       nil
2       nil
3       nil
4       nil



I think we're going to need a considerable amount of time to understand these "nils" everywhere. But, could the (new) undef syntax

 
  t[i] = undef     -- remove a key from a table 
  t[i] == undef    -- test whether a table has a key
  t[i] ~= undef    -- test whether a table has a key

Any other use of 'undef' gives a syntax error.


be tied to the removal of the key/values, if possible (not referenced by something)? maybe, to put the key/value in a high priority (newest always) generation (from the new generational gc), such that we could have a more deterministic memory management. Then, the (new) syntax could be extended to non-tables

a = function(x) return x end
a = undef

as a hint for the gc.

--
Rodrigo Azevedo Moreira da Silva