Skip to content

How to pretty print table values (rather than references)? #39

@moon6969

Description

@moon6969

How can I pretty print a table with the shared references dereferenced?

local serpent = require("serpent")

local shared_table = { a = 'a' }
local main_table = { first = shared_table, second = shared_table }

print("*** line  ***")
print(serpent.line(main_table))

print("*** dump  ***")
print(serpent.dump(main_table))

actual output:

*** line  ***
{first = {a = "a"} --[[table: 0x0002ff00]], second = nil --[[ref]]} --[[table: 0x0002ff60]] --[[incomplete output with shared/self-references skipped]]
*** dump  ***
do local _={second={a="a"},first=nil};local __={};_.first=_.second;return _;end

desired output something like:

{first = {a = "a"}, second = {a = "a"}}

or even better if it could also still indicate which values are shared, perhaps like this...

{first = {a = "a"} --[[table: 0x0002ff00]], second = {a = "a"} --[[ref table: 0x0002ff00]]} --[[table: 0x0002ff60]]

Use case is to quickly see actual table values in one place in a log file.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions