[squeak-dev] Re: Code formatting patterns

Jecel Assumpcao Jr. jecel at merlintec.com
Wed Oct 9 00:47:14 UTC 2013


Bob Arning wrote:

> Not sure you need special magic key. Comments know where they are
> in the text, but could be displayed just about anywhere. Some experiments
> underway at:
> 
> http://69.251.218.6:9116/split

That looks pretty good!

For a very compact Smalltalk that I designed, I didn't add comments to
the language itself but rather had this method for Points:

comment: explanation on: expression
  ^ expression

which allowed code like:

a := b + (15 at 15 comment: 'this is scaled for 32 bit words' on: c*4)

This would work with a very simple text editor and would give the
correct result with a very dumb compiler. But you could have a smarter
compiler notice that the receiver is a constant object and optimize the
message send away. And a fancier editor could show just:

a := b + (c*4)

with the expression in parenthesis having a slightly different
background color, so when you passed the cursor over it the text 'this
is scaled for 32 bit words' would appear at the indicated offset (15 at 15)
from the bottom left of the left parenthesis.

Two advantages of this scheme were that the comment could be any object
at all, and not just Strings, and that the comment refers to a whole
code fragment and not just to a single point in the code text.

-- Jecel



More information about the Squeak-dev mailing list