lua-users home
lua-l archive

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


Speaking of immutable objects and interning, there is an interesting
intermediate possibility: lazy interning.

Basically, an immutable object can be interned when an attempt is made to use it as a table key (and possibly when any equality comparison is done). This might be useful, for example, for immutable vectors representing points,
rectangles, or colours.

This wouldn't work with character strings, without taking some care, because the C API relies on character strings not moving around. However, it would work on an immutable object whose elements could only be accessed through some API call; an immutable tuple of full Lua objects would have to be of
this form.

R.