<div>< What does everyone think of just trying to pretty-print object</div><div>literals with multiple members ></div><div><br></div><div>Pretty-printing those and whatever JS calls its (foo(), bar())</div><div>PROGN-like thing would be the sweet spot. I'd assume the printing</div>

<div>logic would be very similar in both cases.</div><div><br></div><div><br></div><br><div class="gmail_quote">On Mon, Apr 2, 2012 at 1:09 PM, Vladimir Sedach <span dir="ltr"><<a href="mailto:vsedach@gmail.com">vsedach@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Pretty-printing is sort of hackish - there's not really any lookahead<br>
or backtracking, which is why the first example situation happens.<br>
<br>
Maybe that whole approach should be scrapped. What does everyone think<br>
of just trying to pretty-print object literals with multiple members?<br>
(Before, all the key:values were printed on one line)<br>
<br>
Vladimir<br>
<div><div></div><div class="h5"><br>
On Fri, Mar 30, 2012 at 2:42 AM, Daniel Gackle <<a href="mailto:danielgackle@gmail.com">danielgackle@gmail.com</a>> wrote:<br>
> I've been trying to upgrade our PS version and have some problems to<br>
> report. This email concerns issues with the changes to the printer in<br>
> commit 60154a. Accordingly, the code samples below need to be<br>
> formatted in a fixed-width font to be readable. Also, they're all in<br>
> JS rather than PS for obvious reasons. I can provide the corresponding<br>
> PS forms if desired.<br>
><br>
> First, a simple for loop used to be printed like this:<br>
><br>
>    for (var n = 0; n < 10; n += 1) {<br>
>        blah(n);<br>
>    };<br>
><br>
> is now:<br>
><br>
>    for (var n = 0; n < 10;<br>
>         n += 1) {<br>
>        blah(n);<br>
>    };<br>
><br>
> Not sure if that was intended, but it's so nonstandard that I can't<br>
> bear to look at it. If one were going to put line breaks in the for<br>
> loop declaration, surely there ought to be a line per clause rather<br>
> than an arbitrary break between the second and third. But three lines<br>
> is too many and anyway the whole thing is weird; it really belongs<br>
> on one line.<br>
><br>
> Second, there seem to be bugs in how expressions in a comma-delimited<br>
> list are line-separated and indented. Apologies for the contrived JS<br>
> here, but I have to make the lines long enough to trigger an<br>
> indentation. Code that used to be in one line like this:<br>
><br>
>    var obj = (obj3433 = {  }, (obj3433.foooooooooooo =<br>
> 'oooooooooooooooooooooooooooooooo', obj3433.baaaaaaaaar =<br>
> 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', obj3433));<br>
><br>
> is now being indented like this:<br>
><br>
>    var obj = (obj3433 = {  },<br>
>               (obj3433.foooooooooooo = 'oooooooooooooooooooooooooooooooo',<br>
> obj3433.baaaaaaaaar = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', obj3433));<br>
><br>
> I like the idea, but it seems the third (and any subsequent) lines<br>
> ought to be aligned with the second.<br>
><br>
> Here's a real example of the same problem from our code:<br>
><br>
>         var bucket = (g4 = m1 - sol[label],<br>
>                       (g5 = m2 - sol[label],<br>
>  (g6 = rcplus === 'col' ? rect3437[0] : rect3437[2],<br>
>  (g7 = rcplus === 'col' ? rect3437[1] : rect3437[3],<br>
>  rc === 'col' ? [g4, g5, g6, g7] : [g6, g7, g4, g5]))));<br>
><br>
> There are other more complex examples of nested grouped expressions<br>
> that are coming out pretty strangely:<br>
><br>
>     var sh = (<br>
>               obj3439 = { markup : packIgrid(markup), tiling : csh.tiling,<br>
> ultc : ultc,<br>
>          ultr : ultr },<br>
>               (<br>
>  (g3 = (it = csh.coldeltas, it != null && it !== false ? xcopy(it) : null),<br>
>  g3 != null ? (obj3439.coldeltas = g3) : null),<br>
>  (<br>
>  g4 = (it3440 = csh.rowdeltas,<br>
>    it3440 != null && it3440 !== false ? xcopy(it3440) : null),<br>
>  g4 != null ? (obj3439.rowdeltas = g4) : null),<br>
>  obj3439));<br>
><br>
> It does seem like a good idea to not have all this on one line, but<br>
> it's far from clear what the indentation policy is.<br>
><br>
> Similar inconsistencies afflict curly braces:<br>
><br>
>    queueMsg(brl, {<br>
>                    acknowledge : true }, mailbox);<br>
><br>
> or:<br>
><br>
>     return ss.appointmentTicket = { col : c + (cols || 0),<br>
>                                  row : r + (rows || 0) };<br>
><br>
> and here's a monster one:<br>
><br>
> var REGRESSIONS = [{ type : 'js', target : 'ff', file1 : 'f1', file2 : 'f2'<br>
> }, {<br>
><br>
>      type : 'js',<br>
><br>
>      target : 'ie6',<br>
><br>
>      file1 : 'ie61',<br>
><br>
>      file2 : 'ie62' }, {<br>
><br>
>                          type : 'js',<br>
><br>
>                          target : 'ie7',<br>
><br>
>                          file1 : 'ie71',<br>
><br>
>                          file2 : 'ie72' }, {<br>
><br>
>                                              type : 'js',<br>
><br>
>                                              target : 'ie8',<br>
><br>
>                                              file1 : 'ie81',<br>
><br>
>                                              file2 : 'ie82' }, {<br>
><br>
>                                                                  type :<br>
> 'js',<br>
><br>
>                                                                  target :<br>
> 'safari',<br>
><br>
>                                                                  file1 :<br>
> 'saf1',<br>
><br>
>                                                                  file2 :<br>
> 'saf2' }, {<br>
><br>
><br>
>          type : 'js',<br>
><br>
><br>
>          target : 'chrome',<br>
><br>
><br>
>          file1 : 'chr1',<br>
><br>
><br>
>          file2 : 'chr2' }, {<br>
><br>
><br>
>                              type : 'js',<br>
><br>
><br>
>                              target : 'node',<br>
><br>
><br>
>                              file1 : 'n1',<br>
><br>
><br>
>                              file2 : 'n2' }, {<br>
><br>
><br>
>                                                type : 'html',<br>
><br>
><br>
>                                                target : 'ff',<br>
><br>
><br>
>                                                file1 : 'hf1',<br>
><br>
><br>
>                                                file2 : 'hf2' }, {<br>
><br>
><br>
>                                                                   type :<br>
> 'html',<br>
><br>
><br>
>                                                                   target :<br>
> 'ie6',<br>
><br>
><br>
>                                                                   file1 :<br>
> 'hie61',<br>
><br>
><br>
>                                                                   file2 :<br>
> 'hie62' }, {<br>
><br>
><br>
><br>
>            type : 'html',<br>
><br>
><br>
><br>
>            target : 'ie7',<br>
><br>
><br>
><br>
>            file1 : 'hie71',<br>
><br>
><br>
><br>
>            file2 : 'hie72' }, {<br>
><br>
><br>
><br>
>                                 type : 'html',<br>
><br>
><br>
><br>
>                                 target : 'ie8',<br>
><br>
><br>
><br>
>                                 file1 : 'hie81',<br>
><br>
><br>
><br>
>                                 file2 : 'hie82' }, {<br>
><br>
><br>
><br>
>                                                      type : 'html',<br>
><br>
><br>
><br>
>                                                      target : 'safari',<br>
><br>
><br>
><br>
>                                                      file1 : 'hsaf1',<br>
><br>
><br>
><br>
>                                                      file2 : 'hsaf2' }, {<br>
><br>
><br>
><br>
><br>
> type : 'html',<br>
><br>
><br>
><br>
><br>
> target : 'chrome',<br>
><br>
><br>
><br>
><br>
> file1 : 'hchr1',<br>
><br>
><br>
><br>
><br>
> file2 : 'hchr2' }, {<br>
><br>
><br>
><br>
><br>
>                    type : 'css',<br>
><br>
><br>
><br>
><br>
>                    target : 'chrome',<br>
><br>
><br>
><br>
><br>
>                    file1 : 'c1',<br>
><br>
><br>
><br>
><br>
>                    file2 : 'c2' }, {<br>
><br>
><br>
><br>
><br>
>                                      type : 'css',<br>
><br>
><br>
><br>
><br>
>                                      target : 'ie8',<br>
><br>
><br>
><br>
><br>
>                                      file1 : 'ie1',<br>
><br>
><br>
><br>
><br>
>                                      file2 : 'ie2' }];<br>
><br>
> I have some respect for how much harder this problem is than it<br>
> appears to be, having worked on similar issues for our Numen REPL and<br>
> not being too happy with what I came up with. That being said, these<br>
> changes to the printer probably make the JS less readable in our case<br>
> rather than more readable. It would be better to do less and have it<br>
> be consistent. At a minimum, I hope we can fix the more indecorous<br>
> areas.<br>
><br>
> Daniel<br>
><br>
><br>
><br>
><br>
</div></div>> _______________________________________________<br>
> parenscript-devel mailing list<br>
> <a href="mailto:parenscript-devel@common-lisp.net">parenscript-devel@common-lisp.net</a><br>
> <a href="http://lists.common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel" target="_blank">http://lists.common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel</a><br>
><br>
<br>
_______________________________________________<br>
parenscript-devel mailing list<br>
<a href="mailto:parenscript-devel@common-lisp.net">parenscript-devel@common-lisp.net</a><br>
<a href="http://lists.common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel" target="_blank">http://lists.common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel</a><br>
</blockquote></div><br>