Skip to content

Output standardization and formatting #864

Closed
@stormofice

Description

@stormofice

This is related to: #824

The current accepted solution to format output looks somewhat like this:

[#] Informational [and human readable] output
10.0

While this works fine for simple outputs, it does not really transform very well for more formatted output [like tables] as you can see here:
computus output, which is misaligned
The table header is shifted four characters to the right, which breaks the alignment with the actual values below.

As human-readability is important for the AAA, this should be formatted in a better way, so the header conforms to the values below properly.

Now there are several ways to circumvent this, some better and more practical than others:

1. Allow [#] to occur at the end of the string

This may introduce some inconsistencies, as there could be a mix of implementations using [#] at the end instead of the start, but it would be a pretty simple fix for these kinds of issues.

2. Use some kind of zero-width unicode character

It would be possible to print out a unicode character which takes up no space, such as the zero-width space.

Now this has the big advantage of being invisible to someone just executing the implementation or looking at its source code.

However it would be very unintuitive for developers, as you need to copy paste the char in front of every string and depending on the IDE/Text editor this may be more or less difficult. It also may not be displayed properly on GitHub (which makes reviewing harder) or in terminals that do not support non ASCII chars.
Older languages and esolangs may also not have support for unicode characters.

3. Use some kind of control ASCII character

This is basically the same as above, but instead of using a unicode character, it would be possible to use C0/C1 ASCII control codes.

All the points above (unintuive for developers/reviewers, difficulties with rendering) do still apply, but nearly every language does support ASCII.

However this does not seem to be a suitable solution, as these chars often get rendered like this:
control char shown as question mark in box
While I haven't tried all of the control characters, it looks like they all get rendered the same (which disqualifies them, as they are not zero-width in nature, which was the original goal).

4. Use smaller character to indicate non-result output

It would be possible to use | instead of [#], which would mitigate the problem as it does not shift the output as much.
However it would not be that clear to the reader why it is there and it does not look as good as the original solution.


None of these ways seem ideal to me, but currently I think that the first or fourth way would be the best, as the others do have major limitations which may have unforeseen impact in the future.

As this is kind of blocking the output standardization, comments and thoughts on this would be greatly appreciated.

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