[squeak-dev] Re: Formatting?

Bert Freudenberg bert at freudenbergs.de
Wed Jun 1 10:47:53 UTC 2016


The predominant style in Squeak historically has been

	coll do: [:each | each do something]

Ken Beck uses that in his “Best Practice Patterns” too. It’s also produced by our formatter (but we rarely use that because it introduces weird line breaks).

I prefer this style because it seems to be most readable.

I agree with Chris about selectability, but I’d rather fix our double-click selection logic than make the code look weird. Double-clicking on “:foo” should only select “foo”.

- Bert -


> On 31.05.2016, at 23:58, Chris Muller <asqueaker at gmail.com> wrote:
> 
> By "everywhere" I assume you mean the ones just inside my brackets?
> When block arguments are written without a space between the colon and
> variable name, like this:
> 
>   coll do: [:each|each do something]
> 
> then I can't simply double-click the "each" declaration and then use
> Cmd+g to find further occurrences, because double-clicking it also
> selects the colon.
> 
> So, I could write:
> 
>    coll do: [: each|each do something]
> 
> but it looks strange to me.
> 
> But also for easier expression editing.  With no space, it is harder
> to select the inner expression via double clicking just inside the
> opening bracket; because a space there affords the user more width to
> hit the expression than the narrow colon.
> 
> This effect can be verified on a computer with touch pad with
> **separate buttons** (e.g., able to double-click without moving the
> mouse even one pixel).  1) put a space there, 2) place mouse about
> halfway into width of the space.  3) Without touching touch pad,
> double-click to ensure expression is selected.  4) Now single-click to
> deselect expression.  5) Now press [Delete] to delete the space.  6)
> Without touching touch pad, again double-click in the exact same spot.
> The colon is selected instead of the expression.
> 
> On Tue, May 31, 2016 at 4:42 PM, Tobias Pape <Das.Linux at gmx.de> wrote:
>> 
>> On 31.05.2016, at 21:26, commits at source.squeak.org wrote:
>> 
>> 
>>> Item was changed:
>>> ----- Method: PluggableTextMorphPlus>>drawBalloonTextOn: (in category 'drawing') -----
>>> + drawBalloonTextOn: aCanvas
>>> - drawBalloonTextOn: aCanvas
>>>      "Show balloon text in the text morph if it has no contents."
>>> +     textMorph contents ifNotEmpty: [ ^ self ].
>>> +     ([ self balloonText ]
>>> +             on: Error
>>> +             do: [ : err | 'error in balloonText' ]) ifNotNil:
>>> +             [ : text | aCanvas
>>> -
>>> -     textMorph contents ifNotEmpty: [^ self].
>>> -
>>> -     self balloonText ifNotNil: [:text |
>>> -             aCanvas
>>>                      drawString: text
>>> +                     in: (self innerBounds insetBy: (5 @ 2 corner: 0 @ 0))
>>> +                     font: textMorph textStyle defaultFont "I want italic here"
>>> +                     color: (Color gray: 0.7) ]!
>>> -                     in: (self innerBounds insetBy: (5 at 2 corner: 0 at 0))
>>> -                     font: textMorph textStyle defaultFont
>>> -                     color: (Color gray: 0.7)].!
>> 
>> Just curious, why are you adding spaces everywhere?
>> :)
>> Best regards
>>        -toibas
> 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4207 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20160601/244eed74/smime.bin


More information about the Squeak-dev mailing list