lua-users home
lua-l archive

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


On Wed, Jan 19, 2011 at 12:04 PM, Alexander Gladysh <agladysh@gmail.com> wrote:
> ..somehow automagically optimize out tclone() calls for
> the nodes that are never changed? [clone-on-write]

Do you mean, for example, if you have code like this:

  do
    local t2 = tclone(t1)
    [...]
  end

to optimize away the `tclone(t1)` as just `t1` if the code in "[...]"
never writes to t2 and never exposes t2 outside of the block?
Careful: tables have unique identity (t2 ~= t1).  Even if you don't
write to t2, the code in "[...]" might (although unlikely) still
expect that t2 ~= t1.