Skip to content

Canonical string representations #40

Open
@dragoncoder047

Description

@dragoncoder047

Currently the box.cog test fails for Cogni only because I decided to stringify boxes slightly differently.

One of the tests is:

Let E be a List (Box 1 Box 2 Box 3 Box 4);
Set Index 0 E be Index 1 E;
Set Index 1 E be Index 2 E;
Set Index 2 E be Index 3 E;
Set Index 3 E be Index 0 E;
Print E;

Under cognac it gives:

([[[[...]]]] [[[[...]]]] [[[[...]]]] [[[[...]]]])

But under cogni it gives:

(#1=[#2=[#3=[#4=[#1#]]]] #2# #3# #4#)

The reason it does this is I implemented the cyclic printer using Scheme's write-with-shared-structure algorithm. What are your opinions on this format?

I don't see any representational advantage to just bailing and printing ... when a recursive object is detected, because it doesn't show which other object it points back to. Especially with this test, with cognac's stringification it's not clear that the nested boxes are actually pointing to each other and there are only four boxes in use, or each of the elements is four independent boxes that point to themselves in a loop (for a total of 16 boxes in use). With the write/ss form it's clear what points where. Do you agree?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions