[Pharo-project] about code formatting in pharo

Igor Stasenko siguctua at gmail.com
Sun Feb 28 05:23:53 EST 2010


On 28 February 2010 11:58, Stéphane Ducasse <stephane.ducasse at inria.fr> wrote:
> Lukas do you have some code samples.
> Something that I particularly hate is the following
>
>        self bla ifTrue: [
>                ...
>
>        ] ifFalse: [
>                ...
>        ]
>
> That is see in the code.
>
> I want
>        self bla
>                ifTrue: [ ...
>                                        ]
>                ifFalse: [
>                        ...             ]
>
>
+1

But, if there is only single block, i usually typing:

self bla ifTrue: [
    code.
    code.
   ]

also i'm usually putting closing ' ] ' at new line, but indented
relatively to receiver, not like:


self bla ifTrue: [
    code.
    code. ]


Also, if statement ends with ']' , i adding a blank like at the end:


self bla ifTrue: [
    code.
   ].

self bla ifTrue: [
    code.
   ].


>
>> I would use a formatter, like this you can make it really consistent.
>> The RBConfigurableFormatter is pretty good in that, the only thing I
>> don't like is the placing of the square brackets. I should look into
>> fixing that, otherwise it formats exactly the way I would format
>> myself (and in the way you propose).
>
> I would really like to play with the idea of automatic formatting
> to see how it goes.
>
> Stef
>
>>
>> Lukas
>>
>> On 28 February 2010 10:36, stephane ducasse <stephane.ducasse at free.fr> wrote:
>>> Hi guys
>>>
>>> I would like to build a set of canonical code formatting convention for Pharo.
>>> I need your help. Now take time before replying :)
>>> I would like to structure the discussion and proceed step by step. So at max I would like to discuss one or two formatting approach per mail.
>>> Once we agree I would like to define a wiki page.
>>>
>>>
>>> **Space after : rule
>>> =============
>>> for example I would like to always have a space after a :
>>>
>>> classes := Smalltalk allClasses select:[:aClass|
>>>               (aClass class includesSelector: #cleanUp)
>>>                       or:[aClass class includesSelector: #cleanUp:]
>>>       ].
>>>
>>> ->
>>>
>>>
>>> classes := Smalltalk allClasses select: [:aClass|
>>>               (aClass class includesSelector: #cleanUp)
>>>                       or: [aClass class includesSelector: #cleanUp:]
>>>       ].
>>>
>>>
>>> **Block arg rule
>>> =============
>>> Do we want a space before and after block arg
>>>
>>> Smalltalk allClasses select: [:aClass :method|
>>>
>>> -> Smalltalk allClasses select: [ :aClass :method |
>>>
>>>
>>> ** selector or block indented compared to receiver
>>> =======================================
>>>
>>> Finally do we follow kent block ideas?
>>>
>>> classes := Smalltalk allClasses select: [:aClass|
>>>               (aClass class includesSelector: #cleanUp)
>>>                       or: [aClass class includesSelector: #cleanUp:]
>>>       ].
>>>
>>> ->
>>> classes := Smalltalk allClasses
>>>                        select: [:aClass| (aClass class includesSelector: #cleanUp)
>>>                                                        or: [aClass class includesSelector: #cleanUp:]].
>>>
>>> Stef
>>> _______________________________________________
>>> Pharo-project mailing list
>>> Pharo-project at lists.gforge.inria.fr
>>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>>>
>>
>>
>>
>> --
>> Lukas Renggli
>> http://www.lukas-renggli.ch
>>
>> _______________________________________________
>> Pharo-project mailing list
>> Pharo-project at lists.gforge.inria.fr
>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
>
> _______________________________________________
> Pharo-project mailing list
> Pharo-project at lists.gforge.inria.fr
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>



-- 
Best regards,
Igor Stasenko AKA sig.




More information about the Pharo-dev mailing list