-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RFC: recshow #1139
RFC: recshow #1139
Conversation
Btw, is there a good way to include a test/example script with the pull request? |
Also, I should probably make |
If its an actual test, add it to the test suite; for an example, I'd pop it in a gist and link that here. |
Ok, here's a small example then: https://gist.github.com/3304162 |
Here's an interesting idea, regarding showing recursive data structures. If we've already seen something, then there's an expression for it. So we can use that expression as a representation of the thing itself. Example:
This is a hypothetical example — but it would be an ideal way to show this. Even if the shown expression is something fairly complex, this would be possible because Julia is fully expression-oriented, so you can always take an expression that evaluates to something and place it somewhere else. So this would also work: julia> x[1]
{x[1]} Of course, this could be better written as |
Also, this approach would clearly require access to the evaluated expression in the repl. That can certainly be arranged, however. |
I'm not sure that would suit my purposes, which is typically to inspect programmatically generated graphs from the REPL. Also, I'd be a lot more comfortable with a general purpose There could be a use for the kind of thing you're describing, for in-REPL experimentation. But then I think it should limit itself to naming objects by global variables that refer to them, so that you can type in the variable and see what it contains. |
What is the latest on this? We certainly need a better way to show self-referential data, but what approach should we take? |
I'm not sure that there's been any progress on this.
Basically, this requires to know for each object whether it should be named before it is printed, We'll need to give up on at least one of these. This pull request gives up number 5. Besides that, there are a number of decisions to be made (partially dependent on the first answer)
|
Jumping ahead a little. As for the visual format, how about something like
When the graph is acyclic, the output should be able to evaluate to something like the original, just as I think
(Note: The examples above are mockups, not real julia output) |
What are we going to do about this? This pull request has been around for 7 months. |
I was originally very gung-ho about showing everything in a form that would evaluate back to the original version of something, but we ended up not doing that in a lot of places (e.g. displaying arrays), and I think it's better not to. So given that we don't generally do that, it seems fair to give it up. Giving up on property #5 and traversing an entire data structure before printing is probably the best way to go here. Unfortunately, this pull request is now rather old and bringing it up-to-date is likely a fair amount of work (even checking it out and building the state it was once in will take a while, although I might do it on julia.mit.edu with 60 cores or something). @tovioh, can you include an example of the output this produced? |
@StefanKarpinski: I agree that giving up on number 5 seems like the best way out. We should probably have a fresh discussion about the output format. It might very well be that it's easiest to start the implementation afresh as well. Unfortunately, I won't have much time for this for a good while. |
Ok, so it seems like we should close this pull-request in favor of a future one when you get the chance. No worries about the time, but I'm looking forward to it when you do get a chance. |
Ok, sounds fine! |
Closing to be resumed later. |
A first attempt at a
show
function that works for self-referential data, per this discussion:https://groups.google.com/forum/#!topic/julia-dev/qdHQYQb-0XQ
It should work for sets, dicts, composite types that use the default
show
,and other types that call
rshow
rather thanshow
within their ownshow
methods.I wasn't sure how to get it to work with arrays, since they seem to use some
sprintf
andshowcompact
trickery to show themselves.I've replaced most calls to
show
withinbase/
, on the premise thatrshow
should be the user facing function. All of these might not be strictly necessary, but they don't add any overhead to normal shows either.There's probably still some open issues:
recshow
print incrementallyrather than consuming the whole object first?
show, rshow, recshow
Any feedback appreciated!