[SPAM] [squeak-dev] code formatting
Frank Shearar
frank.shearar at angband.za.org
Mon Jun 28 14:07:33 UTC 2010
On 2010/06/28 09:30, Sven Van Caekenberghe wrote:
>
> On 27 Jun 2010, at 22:59, Rob Withers wrote:
>
>> case A:
>> SocketEndpointBottom>>#send: data
>> self isConnected
>> ifTrue: [[self socket sendSomeData: data]
>> on: Error
>> do: [:ex |
>> self socket notNil
>> ifTrue: [self socket closeAndDestroy].
>> SSLSendError signal: ex messageText]]
>> ifFalse: [self socket notNil
>> ifTrue: [self socket closeAndDestroy]]
>
> I like A the best, its the most compact and still sematically structured.
> Personally I add extra space inbetween square brackets, like this:
>
> case A:
> SocketEndpointBottom>>#send: data
> self isConnected
> ifTrue: [ [ self socket sendSomeData: data ]
> on: Error
> do: [ :ex |
> self socket notNil
> ifTrue: [ self socket closeAndDestroy ].
> SSLSendError signal: ex messageText ] ]
> ifFalse: [ self socket notNil
> ifTrue: [ self socket closeAndDestroy ] ]
>
> It gives the code a bit more 'breathing room'.
> I picked this up from exiting code, I see it a lot in the Seaside code base.
I'll second this, on all counts: conserves vertical space, the "] ]"
pattern makes it easier to count brackets, and Seaside uses this style.
It also looks more "lispy" having all the closing ]s on one line. I do
find it difficult to count brackets: shout's highlighting of the pairs
of brackets is a bit subtle for me. (To which the obvious response is:
submit a patch!)
frank
More information about the Squeak-dev
mailing list
|