[squeak-dev] Coding style

Chris Muller asqueaker at gmail.com
Wed Mar 10 21:20:34 UTC 2010


Here are some other factors to consider about formatting.

  - I have proposed Compiler packages which format to a Rectangular
Block style.  They are in the inbox, we can use this for discussion
and collaboration.

  - I like to have some *reason* for our formatting.  Kent Beck's
"best-practice" offers legitimate arguments for the formatting choice
over personal style.

  - The current pretty-print style is unnattractive, hard to read and,
worst, not very functional.

  - By "not very functional" I mean:

    1) Without adequate spacing, it is harder to select "statements"
by clicking just inside Block arguments.
    2)  When there is no space after a block argument, as in, :each,
then double-clicking on it for cut-and-paste purposes requires a fine
motor drag rather than a (gross-motor) double click.  It also seems
inconsistent with method-arguments, which place a space between the
colon and the argument name.
    3) Our differ is line-based. With the current format, diffing puts
too much text on one-line, causing the human to incur, again, work
that should be done by the computer.

If we cannot agree on a final "best" form, perhaps we can agree, for
the sake of productivity, to something that has relatively more
"function" according to the above problems.

I made updates to the work I've done to account for Eliot's and Juan's
taste over my own.  The three of us all like Rectangular Block.

I think we should adopt this into trunk for purely the funtional
producitivity reasons stated, and then someone who hates Rectangular
Block enough should do the work to write something that allows that to
be a formatting preference.

Obviously, no one solution can make everyone happy.  But what's in the
"inbox" is an improvement for the tangible reasons described above,
and for tangible reasons published in a book.  I ask if we can move
forward, one incremental step, and still leave this issue open for
discussion on the table for further improvement.

 - Chris

On Wed, Mar 10, 2010 at 4:25 AM, Bert Freudenberg <bert at freudenbergs.de> wrote:
> On 10.03.2010, at 02:53, commits at source.squeak.org wrote:
>>
>> +     ^packageList ifNil:[packageList := (PackageInfo allPackages collect: [ :each | each packageName]) sort]!
>> -     ^packageList ifNil:[packageList := (MCWorkingCopy allManagers collect:[:each| each packageName]) sort]!
>
>
> This to me replaces one style of too few spaces with another of too many ;)
>
> I'd have written
>
>        collect: [:each | each packageName]
>
> 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's examples:
>
>        http://c2.com/ppr/formatting.html
>
> 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?
>
> Many projects have such rules. One good example IMHO is PEP-8 in the Python community.
>
> For Smalltalk I only know Kent Beck's rules from "Best Practice Patterns" 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?
>
> - Bert - (hoping this does not open a can of worms ...)
>
>
>



More information about the Squeak-dev mailing list