lua-users home
lua-l archive

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

Am 30.06.2016 um 05:01 schröbte Hisham:
On 29 June 2016 at 10:10, Philipp Janda <> wrote:
Am 26.06.2016 um 21:59 schröbte Philipp Janda:

Am 26.06.2016 um 20:23 schröbte Tim Hill:

As I said, the scheme is far from perfect, but it’s more consistent
that the current incoherent approach of .n, # and sequences imho.

I agree. Most of it could be realized via a library without support from
the Lua core ...

I've modified the standard table library to use `.n` instead of `#`. In case
someone else wants to check out how it feels:

     luarocks install --server= table.n

From reading test.lua, the feeling I get is that it feels cumbersome
if t={1,2,3} doesn't work with the `table` functions out of the box. I
wonder if "use n if present, or else just use #" would be a sensible

I already use this approach elsewhere, but the downside is that you don't actually get rid of the undefined behavior of sequences with `nil`s. You would probably run into it less often, but that would make it all the more surprising when you do.

For the standard library, I think it would be confusing (and
perhaps too slow?) in general, but it would make sense for

Since most of the arguments for `table.unpack()` probably come from `table.pack()`, I agree.

-- Hisham