lua-users home
lua-l archive

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


On Jun 28, 2016 2:47 AM, "steve donovan" <steve.j.donovan@gmail.com> wrote:
>
> On Tue, Jun 28, 2016 at 8:41 AM, Daurnimator <quae@daurnimator.com> wrote:
> > Which really doesn't need any changes to lua itself anyway; just a
> > vague agreement on 'one' standard sequence/array/list library.
>
> +1, simple and sweet.  'n' is hidden as it should be.
>

I haven't been following this thread that closely. So I apologize if this has already come up.

Speaking of hidden, it's a big deal whether 'n' is exposed to pairs().

If it is, special work has to be done in exploded-LOM-like keyed lists like

{key="datapoints", 7, 3, nil, 7, n=4}

When you iterate over the non-numeric keys, you also need to skip t.n. And...

If you don't include it in pairs, then

function shallowclone(t)
  local nt={}
  for k,v in pairs(t) do
    nt[k] = v
  end
  return nt
end

is not going to clone all tables.

Jay