lua-users home
lua-l archive

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


So as a start, there needs to be

make_read_only( table )

although that's crazy by itself, as then the runtime would have to check for every access that might modify the table, or elements it refers to. And still it won't work:

const set = { t1, t2, t3 }

t1[ #t1 + 1 ] = ""

In a fully functional language that is probably possible, as nothing that exists gets modified, it's only garbage collected, and new things are just produced. One does not even need "const" there, as everything is const.

To put this in lua, I guess the runtime has to "mark" things as constant, which might be costly.

On 3/8/2012 10:01 PM, steve donovan wrote:
On Fri, Mar 9, 2012 at 7:31 AM, Dimiter 'malkia' Stanev
<malkia@gmail.com>  wrote:
But what happens when some function gets access to the literal and modifies
it?

You would necessarily need the concept of 'readonly tables' here, as a
dynamic construct (to avoid 'const pollution', that is, having to put
static const modifiers on all arguments)

steve d.