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

fix #16815, showing an Enum value should use single-line repr of its type #16817

Merged
merged 1 commit into from
Jun 7, 2016

Conversation

JeffBezanson
Copy link
Member

No description provided.

@vtjnash
Copy link
Member

vtjnash commented Jun 7, 2016

I wonder if this hints that multiline shouldn't have been sticky on the IO stream. E.g. that there should be a show_multiline function (default is to dispatch to show), and otherwise show assumes it should print a single line representation. Are there any examples where having this property silently propagate gives better output?

@nalimilan
Copy link
Member

Also, isn't there a simpler way of representing the name of a type? Why isn't repr or string enough?

@JeffBezanson
Copy link
Member Author

Yes, I think I could have used repr or string, but when printing I prefer to use I/O functions directly instead of converting things to strings first and then printing them.

@vtjnash That's a good point; show functions almost always want to turn multiline off for printing components of an object. But I can't quite stomach adding a function just for this; it seems simpler just to use the mechanism we have.

@nalimilan
Copy link
Member

Well, the new version is terribly obscure and complex IMHO. I don't think anybody is going to find out that's the preferred way of printing components of an object.

@JeffBezanson
Copy link
Member Author

OK, I can imagine handling verbosity via separate functions. Arguably we are already doing that with print vs. show. Previously writemime in some cases was used to mean "most verbose, multiline output", but it doesn't make sense to couple that to MIME types. We could add a third basic printing function, but I think a good test is whether we can think of a good name for it. Maybe something like replshow?

I don't think it's fair to dismiss the current approach as obscure and complex. Issues on this were open for months or years. Before, we had a completely inscrutable nest of output functions, and it wasn't even possible to control output in a general way. The fact that some cases could be handled with concise code didn't prevent loud and frequent complaints.

@nalimilan
Copy link
Member

The new system is clearly a big improvement, not doubt about that. I was just speaking about the specific case of representing the name of a type, which is very simple, and for which I think we need a simple solution. replshow sounds like it's limited to interactive use, which isn't necessarily the case. Maybe a name similar to showcompact, but referring to multiline? Or maybe showcompact could also set :multiline=>false, since that's the most common need?

@JeffBezanson
Copy link
Member Author

Setting multiline to false in showcompact sounds like a good idea.

@JeffBezanson JeffBezanson merged commit d98f2c0 into master Jun 7, 2016
@tkelman tkelman deleted the jb/fix16815 branch June 8, 2016 04:19
nalimilan added a commit that referenced this pull request Jun 9, 2016
This provides a simple way of printing the short representation
of a type. Cf. #16817.
nalimilan added a commit that referenced this pull request Jun 9, 2016
This provides a simple way of printing the short representation
of a type. Cf. #16817.
@nalimilan
Copy link
Member

Found another case of this when printing Nullable, see #16842. I suspect this pattern is quite common when printing custom types.

nalimilan added a commit that referenced this pull request Jun 9, 2016
This provides a simple way of printing the short representation
of a type. Cf. #16817.
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.

3 participants