lua-users home
lua-l archive

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


I've written my own, which I can use in the console using a simple require() to load the function in the console, mw.logObject(t) is not practical at all for its intended use. It still has indentation where line breaks are inserted (not after each key/value pair, it reduced the presentation of keys (when they are numbers or strings not containing spaces, commas, or '=', and escaping the quotes as needed. It also supports the optional numbering of tables/functions (if there's a cycle in a key or value, it just shows a "...", using a much simpler approach to avoid infinite loops that does not need any marking with a store proportional to the number of tables or functions encountered but only proportional to the maximum depth, so it works in the memory constraints of 55MB enforced by Scribunto's sandboxing of Lua and is useful for debugging scripts without breaking them with memory exhaustion errors)

Le lun. 25 mai 2020 à 17:47, Francisco Olarte <folarte@peoplecall.com> a écrit :
Philippe:

On Mon, May 25, 2020 at 4:29 PM Philippe Verdy <verdyp@gmail.com> wrote:
> But there remains the common cases of indexes by numbers, which still require the [] in table constructors.
> Not all tables are constructed as sequences, writing t = {1, 2, 3, [10] = 100,} or t = {'a', 'b', 'c', [25] = 'y', 'z', [-1] = '',} is ugly
> It could simply be  t = {1, 2, 3, 10 = 100,}  or t = {'a', 'b', 'c', 25 = 'y', 'z', -1 = '',}
> Such use is not exceptional, it exists with sparse-indexed lookup tables (which are frequent in many projects). These brackets obscure the data making them unnecessarily long if this is a large table constructor with many keys.

I have no clue of what point you are trying to make here, or what you
are replying to.


> As well the way the tables are dumped in debugging consoles is ugly and verbose,

Mine does not do it.

.....
> "mw.logObject(t)" logs tables and subtables in Wikimedia, .....but a bad design of the mw package for this function,......

Seems you do not like that mw thingie. Why don't you just find another
one that better suits your tastes? Or write your own as I did?

Francisco Olarte