Skip to content
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

show(o::Any) handles circular references #3831

Merged
merged 1 commit into from
Jun 9, 2014
Merged

show(o::Any) handles circular references #3831

merged 1 commit into from
Jun 9, 2014

Conversation

amitmurthy
Copy link
Contributor

This small patch specifically only handles the looping associated with self-referential compound types which do not have a show method.

It is a temporary fix till the larger issues of a better show is available. Works by recording already printed objects in a task local Set.

Will be useful for new user defined types with self-referential objects that do not have a show method.

@jiahao
Copy link
Member

jiahao commented Oct 21, 2013

bump

Is this still relevant for 0.2-rc1?

@StefanKarpinski
Copy link
Member

Now that we're past 0.2, it would be good to revisit this.

@quinnj
Copy link
Member

quinnj commented Jun 3, 2014

Bump. This would be good to have for 0.3 (and this PR has been open a long time...)

@JeffBezanson
Copy link
Member

Ok, let's rebase this, kick the tires, and see if we like it.

@quinnj
Copy link
Member

quinnj commented Jun 3, 2014

Ok, I'm playing around with this. The original from this PR is:

In  [2]: type A
    b
end

In  [3]: type B
       a::A
       function B()
         self = new()
         self.a = A(self)
         self
       end
end

In  [4]: b = B()

Out [4]: B(A(B(# oid 2006584968323742060)))

I don't think showing the object id tells you much, how about something like:

In  [14]: show2(B())
B(A(B(#= circular reference =#)))

@porterjamesj
Copy link
Contributor

Python uses ...:

Python 2.7.6 (default, Nov 15 2013, 15:57:34)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.2.79)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> a = []
>>> a.append(a)
>>> a
[[...]]
>>>

@jiahao
Copy link
Member

jiahao commented Jun 4, 2014

Whereas we could use or the like.

@amitmurthy
Copy link
Contributor Author

Rebased. Uses all 3 of ⥀, ... and the last 6 hex digits of the object id, like this - B(A(B(⥀ ...0ca5ab))) .

But I am neutral to any representation. Just thought that the object id may help in multiple circular references.

@quinnj
Copy link
Member

quinnj commented Jun 4, 2014

I still vote for

In  [14]: show2(B())
B(A(B(#= circular reference =#)))

Very clear that something different is happening (in the case you accidently create a circular reference). And it uses a #= =# comment, and those are just nifty :)

@amitmurthy
Copy link
Contributor Author

Have changed it to #= circular reference =# . Will go ahead and merge after a day or two if there are no objections.

@quinnj
Copy link
Member

quinnj commented Jun 6, 2014

+1

amitmurthy added a commit that referenced this pull request Jun 9, 2014
show(o::Any) handles circular references
@amitmurthy amitmurthy merged commit af9ec2b into JuliaLang:master Jun 9, 2014
IanButterworth pushed a commit that referenced this pull request Mar 8, 2024
Stdlib: Pkg
URL: https://github.com/JuliaLang/Pkg.jl.git
Stdlib branch: master
Julia branch: master
Old commit: e7d740ac8
New commit: 56c379045
Julia version: 1.12.0-DEV
Pkg version: 1.11.0(Does not match)
Bump invoked by: @KristofferC
Powered by:
[BumpStdlibs.jl](https://github.com/JuliaLang/BumpStdlibs.jl)

Diff:
JuliaLang/Pkg.jl@e7d740a...56c3790

```
$ git log --oneline e7d740ac8..56c379045
56c379045 make `delayed_delete_dir` usage a bit more backwards compatible (#3830)
5a68d7953 restore unwrap UnstableIO in precompile (#3831)
```

Co-authored-by: Dilum Aluthge <[email protected]>
mkitti pushed a commit to mkitti/julia that referenced this pull request Apr 13, 2024
…#53637)

Stdlib: Pkg
URL: https://github.com/JuliaLang/Pkg.jl.git
Stdlib branch: master
Julia branch: master
Old commit: e7d740ac8
New commit: 56c379045
Julia version: 1.12.0-DEV
Pkg version: 1.11.0(Does not match)
Bump invoked by: @KristofferC
Powered by:
[BumpStdlibs.jl](https://github.com/JuliaLang/BumpStdlibs.jl)

Diff:
JuliaLang/Pkg.jl@e7d740a...56c3790

```
$ git log --oneline e7d740ac8..56c379045
56c379045 make `delayed_delete_dir` usage a bit more backwards compatible (JuliaLang#3830)
5a68d7953 restore unwrap UnstableIO in precompile (JuliaLang#3831)
```

Co-authored-by: Dilum Aluthge <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants