beyond-all-reason / beyond-all-reason/RecoilEngine
Make Spring.Echo (and Spring.Log?) print out table contents
- Dominant language
- C++
- Stars
- 679
- Forks
- 290
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 40
Description
Right now if you do like
```lua
t = { foo = "bar", baz = 1337, quux = function() end, sub = { xyz = 123 } }
Spring.Echo(t)
```
you just get "\". Make it so the above prints something along the lines of
```
{
foo = "bar",
baz = 1337,
quux = ,
sub = {
xyz = 123,
},
}
```
Caveats:
* strings and numbers are different types, e.g. `{ ["1"] = 1, [1] = "1" }` should probably be printed with the explicit \" and \[\]
* you can create recursive tables, e.g. `x = {}; y = { .t = x }; x.t = y` or `t = {}; t.t = t`.
* you can have a huge table referenced many times, e.g. `x = { billion entries }; y = {x, x, x, x, ...}; Spring.Echo(y)`
* for the two cases above, perhaps an already-printed table can be referenced by name of first encounter within the current table. So if you have
```lua
a, b, c = {}, {}, {}
t = {
foo = {
bar = { a, "x", b }
baz = a,
quux = {c, a}
}
bla = {c, c}
bla2 = b
}
c.t = t
t.bla[3] = t.foo.bar
Spring.Echo(t)
```
it would print something like
```
{
foo = {
bar = { {}, "x", {}, },
baz = ,
quux = {
{ t = , },
,
},
},
bla = {
,
,
,
},
bla2 = ,
}
```
* would be ideal if the format was such that for simple types (i.e. apart from the etc and the edge cases above) you could copy-paste it from infolog and it would be valid Lua.
* would be ideal if whitespace wasn't excessively verbose. If a table looks like `{ 'a', 'b', 'c' }` then it would ideally be printed as `{ 'a', 'b', 'c' }` and not as
```
{
[1] = "a",
[2] = "b",
[3] = "c",
}
```
Contributor guide
Research direction
Start by locating the implementation or binding for Spring.Echo and Spring.Log; the issue names no files or tests. Completion should cover readable table contents, compact simple values, distinct string and number keys, and safe handling of recursive or repeatedly referenced tables without runaway output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, lua
- Domain
- observability
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100