[squeak-dev] Formatting?

Bert Freudenberg bert at freudenbergs.de
Wed Jun 1 20:45:37 UTC 2016


> 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]]

or maybe

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

> 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.


> 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]).

> 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.

- Bert -



-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4207 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20160601/03c1170a/smime.bin


More information about the Squeak-dev mailing list