Intervals

Bob Arning arning at charm.net
Mon Nov 29 16:56:49 UTC 1999


On Mon, 29 Nov 1999 08:00:28 -0800 Dan Ingalls <Dan.Ingalls at disney.com> wrote:
>Here is a place that I wish we had a type inference system
>working already, because then we could examine all the place where #includes:
>was being sent to an interval, and decide which meaning was intended.

Short of that, an empirical approach may provide useful (though not necessarily complete) information. The idea would be to watch for any invocation of Interval>>includes: and record that fact. Later examination of the data collected (if any) could point to places that need fixing. Enclosed is a snippet to do that (it could be easily modified to watch for just about anything).

Cheers,
Bob

========
'From Squeak2.7alpha of 9 November 1999 [latest update: #1660] on 29 November 1999 at 11:41:18 am'!
Object subclass: #FlagWatcher
	instanceVariableNames: ''
	classVariableNames: 'Gotchas '
	poolDictionaries: ''
	category: 'Kernel-Objects'!

!Object methodsFor: 'flagging' stamp: 'RAA 11/29/1999 11:41'!
flag: aSymbol
	"Send this message, with a relevant symbol as argument, to flag a message for subsequent retrieval.  For example, you might put the following line in a number of messages:
	self flag: #returnHereUrgently
	Then, to retrieve all such messages, browse all senders of #returnHereUrgently."

	aSymbol == #rangeIncludes ifTrue: [
		FlagWatcher gotcha: thisContext shortStack.
	].! !


!FlagWatcher commentStamp: 'RAA 11/29/1999 11:40' prior: 0!
I am used to collect interesting things for later examination. To add something to me, do

	FlagWatcher gotcha: 'anything you like'.

To find out what has been seen so far (and to reset the current collection) do

	FlagWatcher show.!

!FlagWatcher class methodsFor: 'as yet unclassified' stamp: 'RAA 11/29/1999 11:37'!
gotcha: something

	(Gotchas ifNil: [Gotchas _ Bag new]) add: something! !

!FlagWatcher class methodsFor: 'as yet unclassified' stamp: 'RAA 11/29/1999 11:38'!
show

	| temp |
	Gotchas ifNil: [^1 beep].
	temp _ Gotchas.
	Gotchas _ nil.
	temp sortedCounts inspect.
! !


!Interval methodsFor: 'accessing' stamp: 'RAA 11/29/1999 11:35'!
includes: aNumber
	
	self flag: #rangeIncludes.
	^ aNumber between: self first and: self last! !





More information about the Squeak-dev mailing list