Skip to content

pointer chain information is not adequate to rebuild data structure #2

@kortschak

Description

@kortschak

Given an adequately clever parser and type constructor, we still cannot unambiguously recreate a data structure from the output of utter when there are pointers to non-pointer values.

In the case of pointers to concrete values, there is no address information given for the target, so for example:

c := []interface{}{5, 5, nil, nil}
c[2] = &c[0]
c[3] = &c[0]

ptrDump := utter.NewDefaultConfig()
ptrDump.CommentPointers = true

ptrDump(c)

gives:

[]interface{}{
    int(5),
    int(5),
    &int /*0xc20803e840*/ (5),
    &int /*0xc20803e840*/ (5),
}

To get this information and only report it where necessary we need to walk the structure once before the dump and mark concrete values that are referenced by a pointer.

Another complication is of how to deal with pointers into []byte. To not interfere with []byte formatting, I think the best approach is to add an appendix comment to []byte rendering to list elements that are referenced and their addresss.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions