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

Pretty printer should output the maximum it can in one line #1383

Closed
josevalim opened this Issue Jul 6, 2013 · 5 comments

Comments

Projects
None yet
4 participants
@josevalim
Member

josevalim commented Jul 6, 2013

iex(5)> Enum.to_list 1..100
[1,
 2,
 3,
 4,
 5,
 6,
 7,
 8,
 9,
 10,
 11,
 12,
 13,

We should always output the maximum we can into a single line and just then go to the next one using the nesting. @brunoro could you please give us hand? :)

@brunoro

This comment has been minimized.

Show comment
Hide comment
@brunoro

brunoro Jul 6, 2013

Contributor

I think that none of the pretty-printing algorithms I've looked into could handle something like that by itself.
Maybe we could try to regroup short terms somehow to force the pretty printer to behave that way. I'll give it a try ;)

Contributor

brunoro commented Jul 6, 2013

I think that none of the pretty-printing algorithms I've looked into could handle something like that by itself.
Maybe we could try to regroup short terms somehow to force the pretty printer to behave that way. I'll give it a try ;)

@josevalim

This comment has been minimized.

Show comment
Hide comment
@josevalim

josevalim Jul 6, 2013

Member

If it helps, the erlang one does it:

6> io:format("~p~n", [lists:seq(1, 100)]).
[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,
 29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,
 54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,
 79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100]
Member

josevalim commented Jul 6, 2013

If it helps, the erlang one does it:

6> io:format("~p~n", [lists:seq(1, 100)]).
[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,
 29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,
 54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,
 79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100]
@brunoro

This comment has been minimized.

Show comment
Hide comment
@brunoro

brunoro Jul 6, 2013

Contributor

It does! Even if the Erlang implementation uses the Hughes algorithm, that behavior is related to the way the document is structured (grouping) rather than to the pretty printer itself.

By looking at http://www.erlang.org/doc/man/prettypr.html I guess we need something like prettypr:par/2. Currently we have something more like prettypr:sep/1 being used for printing sequences.

Contributor

brunoro commented Jul 6, 2013

It does! Even if the Erlang implementation uses the Hughes algorithm, that behavior is related to the way the document is structured (grouping) rather than to the pretty printer itself.

By looking at http://www.erlang.org/doc/man/prettypr.html I guess we need something like prettypr:par/2. Currently we have something more like prettypr:sep/1 being used for printing sequences.

@gerred

This comment has been minimized.

Show comment
Hide comment
@gerred

gerred Jul 8, 2013

I'm happy to take this on - where would I look for the existing pretty printing?

gerred commented Jul 8, 2013

I'm happy to take this on - where would I look for the existing pretty printing?

@josevalim josevalim closed this in 2dc1e41 Jul 9, 2013

@edgurgel

This comment has been minimized.

Show comment
Hide comment
@edgurgel

edgurgel Jul 9, 2013

Contributor

@gerred, @josevalim was too fast :)

Contributor

edgurgel commented Jul 9, 2013

@gerred, @josevalim was too fast :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment