[KCP] SystemDictionary cleaning: Comments and design

Richard A. O'Keefe ok at cs.otago.ac.nz
Thu Jun 12 02:03:00 UTC 2003


Stephane Ducasse <ducasse at iam.unibe.ch> wrote:
	PS: You should have told us what Utilities pointOrNilFrom: '2,6' does 
	exactly.
	Because this is obscure to me.
	
It returns 2 at 6.

The comment in the method is not only badly spelled, it says # when
it means @.  I don't know who 'sw' is, but the method went in on
2002.06.10

I don't know why it restricts the operands to SmallInteger; why not
any Number?

Since this is about creating Points, it clearly belongs in Point.

Redesigned a bit, we'd have

    Point class>>
    readFrom: aStringOrStream ifInvalid: aBlock
        |tokens|
        tokens := Scanner new scanTokens: (aStringOrStream isStream
                      ifTrue:  [aStringOrStream contents]
                      ifFalse: [aStringOrStream].
        ^(tokens size = 3 and: [
          tokens first isNumber and: [
          (tokens second == #@ or: [tokens second == #,]) and: [
          tokens third isNumber]]]
	 ) ifTrue: [tokens first @ tokens third]
	   ifFalse: [aBlock value]

The only use of #pointOrNilFrom: I can find is in
Utilities class>>obtainArrowheadFor:defaultValue:
There are two uses of _that_.  One is in
Preferences class>>setArrowheads, and the other is in
Morph setArrowheads.
All of these were added about the same time by the same person,
for good reason.

I would rather set arrowhead size by dragging a rectangle than
by typing in a string.  However, the present #obtainArrowheadFor:defaultValue:
should work in an MVC project as well as in a Morphic project.



More information about the Squeak-dev mailing list