[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: First impressions and errata
- From: Andrew Starks <andrew.starks@...>
- Date: Sun, 23 Feb 2014 09:33:49 -0600
On Sunday, February 23, 2014, Enrico Colombini <erix@erix.it> wrote:
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
No vase opened! I assumed you were speaking to a module or alternate interpreter.
The lack of a built in pretty printer is an excellent opportunity to learn a bit of lua and it's absence is an effective lesson, in and if itself. :)