Finding classes by their comments

Richard A. O'Keefe ok at atlas.otago.ac.nz
Tue Apr 24 01:34:15 UTC 2001


"Bert" wrote:
	Actually, when I am looking for something like this I just type
	it into a workspace.

Yes, but the context was not "what do people thoroughly familiar with ST do"
but "what is the IDE like".

	And when the search for URI comes up empty, I replace URL for it.
	And voila, 26 occurrences:
	
That wasn't the point.  The point was that it is easy to extend the IDE.

	> One of them is required because Text can't make up its mind how
	> thoroughly it wants to emulate String.
	
	RTFC before making such bold comments.

Oh, but I *did*.

	There are only very few methods
	just forwarding the method to the embedded string. I counted 3 out of 49:
	two variants of #findString plus #lineCount. Compare this to the 165
	methods of String.
	
includesSubString: *is* a variant of findString: .  But in any case, you
counted wrong.  You forgot
	size
	at:
	at:put:
	copy
plus all the others that they share by virtue of being ArrayedCollections.

String has 337 selectors not inherited from Object, 117 not shared with Text.
Text   has 242 selectors not inherited from Object,  22 not shared with String.

    o := Object allSelectors asSet.
    s := String allSelectors asSet.
    s removeAll: o.
    s size
=>  337
    t := Text allSelectors asSet.
    t removeAll: o.
    t size
=>  242
    r := s copy.
    s removeAllFoundIn: t.
    s size
=>  117
    t removeAllFoundIn: r.
    t size
=>  22
    t
=>  a Set(#makeBoldFront:to: #append: #attributesAt:forStyle: #emphasisAt:
	  #removeAttribute:from:to: #attributesAt: #fontAt:withStyle:
	  #makeSelectorBoldIn: #string #setString:setRunsChecking: #runs
	  #unembellished #addAttribute:from:to: #addAttribute:
	  #embeddedMorphs #allBold #find: #couldDeriveFromPrettyPrinting
	  #setString:setRuns: #fontNumberAt: #rangeOf:startingAt:forStyle:
	  #runLengthFor:)

That is, Text shares fully 90.9% of its non-Object methods with String.

What does String have that text lacks?

(a) Ordering (< and friends, including alike: and compare:)
(b) Conversions (asCharacter, asDate, asFileName, asInteger, and so on).
    Oddly, Text *does* have asNumber, but not asInteger.
(c) Spelling correction
(d) display{At:,On:,On:at:}
(e) Substring comparison (beginsWith:, endsWith:, endsWithAnyOf:, ...,
    lastSpacePosition, ...
(f) A whole bunch of find* and indexOf* methods that make perfect sense
    for Text.
(g) Stuff for parsing, like #keywords.
(h) Case conversion
(i) Line ending conversion
(j) Miscellaneous.

Does it really make sense for Text to have #asUrl but not #asFileName?
To have #asNumber but not #asInteger?
To have #findString:startingAt: but not #includesSubString: (which is
defined as
    ^(self findString: subString startingAt: 1) > 0       )?

Much of this lot *doesn't* make much sense for Text.   But with
#findString:startingAt:  there, it's clear that looking at/for
substrings *does* make sense for Text.

RTFC indeed!





More information about the Squeak-dev mailing list