[Pharo-project] about code formatting in pharo

Adrian Lienhard adi at netstyle.ch
Sun Feb 28 16:29:22 EST 2010


On Feb 28, 2010, at 22:12 , Stéphane Ducasse wrote:
>> ---------------
>> 1
>> 	to: (mine size min: his size)
>> 	do: [ :index |
>> 		(mine at: index) = (his at: index) ifTrue: [
>> 			self
>> 				instVarAt: index
>> 				put: (anotherObject instVarAt: index) ] ].
>> ---------------
>> 
>> Putting "[ :ind |" on a new line and using multiple tab indentation looks horrible to me.
> 
> :)
> 
> why not like that?
>> 1
>> 	to: (mine size min: his size)
>> 	do: [ :index |
>> 		(mine at: index) = (his at: index)
>> 			ifTrue: [ self
>> 					instVarAt: index
>> 					put: (anotherObject instVarAt: index) ] ].

The difference is not big, but I prefer the first version because you get one indentation less (and you don't break the rule that an indentation always has only one tab, which is not the case above).

Also it makes formatting of conditionals consistent with the formatting of other messages, e.g.,

receiver foo: x

instead of

receiver
	foo: x


The rule for ifTrue:ifFalse: follows the same rule, i.e., that keyword messages with more than one argument are put on separate lines:

receiver
	foo: x
	bar: y


Adrian



More information about the Pharo-dev mailing list