Newsgroups: comp.lang.smalltalk
Path: cantaloupe.srv.cs.cmu.edu!europa.chnt.gtegsc.com!news.mathworks.com!news.kei.com!simtel!col.hp.com!news.dtc.hp.com!hplextra!hplb!gw
From: gw@hplb.hpl.hp.com (Gunther Walther)
Subject: Re: Smalltalk formatting styles...
Sender: news@hplb.hpl.hp.com (Usenet News Administrator)
Message-ID: <D81t6L.575@hplb.hpl.hp.com>
Date: Thu, 4 May 1995 10:01:32 GMT
References: <D7y4tp.Dp6@hplb.hpl.hp.com> <NEWTNews.12603.799538101.Postmaster@g3148077.ga.bst.bls.com>
Nntp-Posting-Host: gwalther.hpl.hp.com
Organization: Hewlett-Packard Laboratories, Bristol, England
X-Newsreader: TIN [version 1.2 PL0.7]
Lines: 73

chris.normand@bridge.bst.bls.com wrote:

: Normal 'C' stlye wants to match up (), [] and {}.  In Smalltalk, since we don't want to 
: waste the vertical space, use:

: 	( ( 3 + 4 ) > 5 )
: 		ifTrue: [ "do something here" ]
: 		ifFalse: [ 
: 			"This will never happen, but it"
: 			"contains more than one line of code"
: 			"So the code should start on the following"
: 			"line and indented another TAB" ].

I know I would be beaten up for my statement "Stick to your C style",
but thats half the fun ;-). However I would like to point out a number of things.

A) I agree with the goal of not wasting vertical space. I would format the
   example above in the following way: (which requires 1 line more, not a
   huge difference, but it also takes one tab less).

 	( ( 3 + 4 ) > 5 ) ifTrue: [
		"do something here" i
	] ifFalse: [ 
		"This will never happen, but it"
 		"contains more than one line of code"
 		"So the code should start on the following"
 		"line (and not indented another TAB, why should it?)"
	]

B) If vertical space would be a concern for all smalltalkers, why
   format things like
	x := AObject
		parameter1: a1
		parameter2: a2.
   I see the point, when a1 and a2 are large expressions, but
   doing it always? 

C) The VisualWorks editor (a very simple editor) come with a
   facility to match up braces. Now if matching up braces in
   Smalltalk is so simple, why is it supported? 

D) I like the abstraction of everything being a message send,
   but if it results in a control, why not format it in a way
   that stresses this. That goes along the lines of expressing
   intention, not mechanics.

E) The block style below leads to missalignment of things that
   should be aligned.
	[a := 2.
	b:= 3.]

F) The default formatter in VisualWorks, results often in lines
   that end like  ]]]]]]]. IMHO, this is not readable.


I would love to have a ST style to believe in, but I have real
problems with the ]]]]]]]. The sole existence of this thread
shows that there is no agreement on a single style.

Cheers,

gunther

PS: The majority of programmers are C programmers. If I can make my
    code more readable to them, why should I not?

--
------------------------------------------------------------------
Gunther Walther                 | Phone: +44 117 9228518 (direct)
Hewlett-Packard Laboratories,   |    or: +44 117 9799910 x28518  
Filton Road, Stoke Gifford,     | FAX:   +44 117 9228972
Bristol, BS12 6QZ, U.K.         | EMAIL: gw@hplb.hpl.hp.com
NOTE THAT BRISTOL HAS NOW A NEW AREA CODE: 117 9 CHANGE YOUR RECORDS
