[squeak-dev] Formatting?

Eliot Miranda eliot.miranda at gmail.com
Thu Jun 2 00:26:39 UTC 2016


On Wed, Jun 1, 2016 at 1:45 PM, Bert Freudenberg <bert at freudenbergs.de>
wrote:

>
> > On 01.06.2016, at 17:46, Chris Muller <asqueaker at gmail.com> wrote:
> >
> >>> The predominant style in Squeak historically has been
> >>>
> >>>        coll do: [:each | each do something]
> >>>
> >>> Ken Beck uses that in his “Best Practice Patterns” too. It’s also
> produced
> >>> by our formatter (but we rarely use that because it introduces weird
> line
> >>> breaks).
> >
> > Actually, Kent Beck advocates a Rectangular Block formatting pattern,
>
> I was mostly talking about the issue at hand, namely, whether to put
> spaces inside of the brackets. Which he does not do.
>
> This is (not entirely by coincidence) the typographical convention in
> English, too.
>
> That’s why I prefer it, independent of rectangular blocks or not.
>
> > which is NOT produced by our formatter, unless you merge
> > Compiler-cmm.179 (which I've just recopied to the Inbox).  I wasn't
> > successful in convincing the community to adopt it six years ago.
> >
> > Besides the reasons already documented by Kents pattern, I like RB
> > because it presents a semi-"tiled" view of the code similar to
> > Scratch, but with textual, rather than graphical, tiles.  Like this:
> >
> >      coll do:
> >            [ :each |
> >            statement1.
> >            (condition1) ifTrue: [ statement2 ] ]
> >
>
> I’d write it Kent Beck-style, namely
>
>
>     coll do:
>            [:each |
>            statement1.
>            (condition1) ifTrue: [statement2]]
>

+1


>
> or maybe
>
>     coll do: [:each |
>            statement1.
>            (condition1) ifTrue: [statement2]]
>

-1.  Blocks braces should delineate rectangular areas for us visual
thinkers.  So it's fine if it fits on one line, but if it fits on two,
break to a new line and indent please.


>
> > It is so much more OO than "textual" formatting like this:
> >
> >      coll do: [ :each |
> >             statement1.
> >             (condition1) ifTrue: [
> >                    statement2.
> >             ]
> >      ]
>
> Agreed. I don’t think I’ve seen much of this style in Squeak. It’s ugly.
>

All to much of it exists in some places I won't illuminate.  Agreed; I find
it both horribly ugly and wasteful of screen real estate.


>
>
> > I really don't notice any predominant style among different authors of
> > Squeak,
>
> I do. Anything that’s not written in that style looks jarring to me. Like
> Andreas’ habit of omitting the space between a keyword message and a block
> (ifTrue:[foo]).
>

+1.


>
> > and I don't think attempting to establish any kind of
> > formatting standard or style would be counterproductive for the
> > community (not that anyone is suggesting that).  Instead, its probably
> > best to let our individual imaginations flow the way they do, and let
> > the IDE take care of each of us individually.  Methods can be quickly
> > and easily formatted on access and/or save.  However, I do recommend,
> > if one is only changing only one or two lines of a longer method, they
> > should try to maintain the prior author's format.  Also, never submit
> > a change to trunk that ONLY changes the formatting of a method,
> > please.
>
> IMHO readability suffers wth mixed styles. Be creative in your coding, not
> in your formatting. I think it would be a good idea to adopt a style guide.
> Beck’s would be a good starting point.
>

+1.  But having a good formatter which can implement Kent's style guide
would be nice.  We're not there yet.

I wonder if we should include a précis of Kent;s guide in a workspace
window in new releases.  We could put a short guide/cheat sheet in one, and
a formatting guide in another.

- Bert -
>

_,,,^..^,,,_
best, Eliot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20160601/6b70bd72/attachment-0001.htm


More information about the Squeak-dev mailing list