lua-users home
lua-l archive

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


On 23/02/2014 15.52, Philipp Janda wrote:

I would also prefer a Lua-like syntax, and I suggest the following
modifications to the original proposal:

*   Count the sequence elements via `ipairs()`, but only display N of
them in case there are more than that (maybe some from the sequence end,
the rest starting at index 1)
*   Then print at most N values using `pairs()` but skip integer keys
between 1 and the sequence end determined above.
*   Write out a marker (e.g. `...`) unless you display all elements.
*   Make N a global variable so that you can change the number of
displayed elements in case the default is not good enough.
*   Abbreviate long keys/values, escape non-printable characters ;-).
*   Try to fit multiple key-value pairs on a single line, but wrap
around at say 80 characters.
*   Respect `__tostring`, but indicate original type.

More than reasonable (even if it goes against reparseable output); I certainly wouldn't want to print a 1M-element list to the console.

Of course a list printer (which is, after all, just a minor convenience) would make the interpreter a lot more complex and will never satisfy everybody. Apologies for uncovering a Pandora vase ;-)

--
  Enrico