<br><br><div class="gmail_quote">On Wed, Mar 10, 2010 at 4:47 AM, Levente Uzonyi <span dir="ltr">&lt;<a href="mailto:leves@elte.hu">leves@elte.hu</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On Wed, 10 Mar 2010, Bert Freudenberg wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 10.03.2010, at 02:53, <a href="mailto:commits@source.squeak.org" target="_blank">commits@source.squeak.org</a> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
+       ^packageList ifNil:[packageList := (PackageInfo allPackages collect: [ :each | each packageName]) sort]!<br>
-       ^packageList ifNil:[packageList := (MCWorkingCopy allManagers collect:[:each| each packageName]) sort]!<br>
</blockquote>
<br>
<br>
This to me replaces one style of too few spaces with another of too many ;)<br>
<br>
I&#39;d have written<br>
<br>
        collect: [:each | each packageName]<br>
<br>
but I just looked at the Blue Book and there indeed is a space before and after a block argument. OTOH it does conform to Kent&#39;s examples:<br>
<br>
        <a href="http://c2.com/ppr/formatting.html" target="_blank">http://c2.com/ppr/formatting.html</a><br>
<br>
</blockquote>
<br></div>
I try not to change the formatting of methods written by others to my taste, but there are times when I just can&#39;t stop myself. This one liner is half baked though...<br>
If this was written by me entirely it would look like something like this:<div class="im"><br>
<br>
        ^packageList ifNil: [<br>
                packageList := (PackageInfo allPackages collect: [ :each |<br>
                        each packageName ]) sort ]<br>
<br></div>
I used to add a space before and after all [ and ].<div class="im"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Generally I feel this is not much of a problem. But I have occasionally seen rather strange formatting, So for the benefit of better readability, do we want to have general rules for formatting code?<br>
<br>
Many projects have such rules. One good example IMHO is PEP-8 in the Python community.<br>
<br>
For Smalltalk I only know Kent Beck&#39;s rules from &quot;Best Practice Patterns&quot; which seem like a good set. And IMHO any rules are better than none, so maybe we want to just agree that if in doubt, follow that suggested practice?<br>

<br>
</blockquote>
<br></div>
If someone has his/her own code formatting rules, he/she will hardly change to another. I find my rules (which are mostly based on this book: <a href="http://stephane.ducasse.free.fr/FreeBooks/WithStyle/SmalltalkWithStyle.pdf" target="_blank">http://stephane.ducasse.free.fr/FreeBooks/WithStyle/SmalltalkWithStyle.pdf</a> ) very readable, especially with shout which colorizes the brackets too.<br>

<br>
Therefore I&#39;m against of forcing a single code formatting. I personally dislike Kent&#39;s &quot;rectangular block&quot; idea.<br>
For example:<br>
I found this more readable<br>
<br>
aCollection<br>
        do: [ :each |<br>
                stream<br>
                        nextPut: $(;<br>
                        print: each;<br>
                        nextPut: $) ]<br>
        separatedBy: [<br>
                stream<br>
                        nextPut: $,;<br>
                        space ]<br>
<br>
than this<br>
<br>
aCollection<br>
        do:<br>
                [:each |<br>
                stream<br>
                        nextPut: $(;<br>
                        print: each;<br>
                        nextPut: $)]<br>
        separatedBy:<br>
                [stream<br>
                        nextPut: $,;<br>
                        space]<br>
<br>
You can notice the rectangular shape in both examples.<br></blockquote><div><br></div><div>But with Kent&#39;s approach a block&#39;s contents lie within its rectangular area.  With your first example only &quot;Put: $(;&quot; and &quot;ce&quot; lie within the block and that breaks the appearance of a rectangular block, being more like a potato sack bulging at the side ;) and is inelegant, ugly, etc, etc.  So...</div>
<div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">I think the best would be a highly customizable pretty printer which would allow anyone to read all methods formatted in the way he/she prefers.<br>
</blockquote><div><br></div><div>+1</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><font color="#888888">
<br>
<br>
Levente</font><div><div></div><div class="h5"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
- Bert - (hoping this does not open a can of worms ...)<br>
</blockquote>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<br>
<br>
</blockquote>
<br>
</div></div></blockquote></div><br>