lua-users home
lua-l archive

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


From: "Jonathan Branam" <sspeare@sspeare.com>
| introduce the concept of
| "const data" to the Lua GC. All of this (somehow specially marked)
| const data would be placed in a separate set of structures in
| Lua. When GC fired, it would simply not check this set at all.
| Also, if a non-const piece of data were to reference this set,
| the GC would not need to continue collecting in the const data.

Sounds interesting. I think you'd have a const ref rather than const data, ie.
to always retain a reference to some data. If the reference to the data changed
and it was the only reference you couldnt retrieve it (ie. a leak).

eg.
const t = { a=1,b=2,c=3 }
function const x ()
  local a = 5
  local const b = 7
end

Neither x or b could be reassigned and would not need to be marked and sweeped.
b would have to be static, ie, you would not create 7 every time. consts would
only be collected when the state closed. If const was used extensively, garbage
collection would be a tad quicker methinks.

N