uiua-lang/uiua

suggestion: repr function

ArseniyKorobenko opened this issue · 2 comments

Python provides 2 ways of stringifying an object: str(), used for pretty printing and repr(), which gives a representation that can be pasted back into the interpreter and evaluated to the get the same value.

Sometimes it's very useful to print values and then paste them into your code for testing purposes, but currently that requires a lot of editing, especially for boxed strings and multidimensional arrays.

I propose adding a repr function that is similar to Python's repr(), which is going to solve that problem.

It could extend the unparse functionality or remain without a glyph

I think I could implement this function myself actually. if you don't mind it being added

I have pushed a commit that makes unparse and $"_" output the "generic" version of a number, i.e. one that should be acceptable by non-Uiua parsers. -5 instead of ¯5, etc.
&s and general output will still be Uiua formatted.
A repr built-in would be acceptable though, if you want to implement it.