Is #smartInspect all that smart?

Bob Arning arning at charm.net
Wed Dec 15 17:16:07 UTC 1999


A little story:

While I was taking a look at the browser menu changes submitted by Marcus, I spotted some code which puzzled me at first: the use of a single dash as an element in a literal array. So I highlighted the code and inspected the result. There were all the entries (many of which were of a more familiar type). I scrolled down the inspector to an element that printed as a dash on the right and inspected it. The new inspector informed me that this was a Character. Interesting, I thought, how did he do that without a $ in front of the dash? I looked at the code which would receive this array and saw that it was comparing #- to the element. And it worked! So Symbols can be equal to Characters? I didn't know that, so I browsed Symbol to see how this was done. It wasn't. A little more digging showed that the Inspector had misled me again with #smartInspect. We fixed this some time ago for Semaphore and now I have fallen for the same thing again with Symbol.

So the question:

Does #smartInspect really help? For all subclasses of SequenceableCollection (except Semaphore) it shows the collection normally UNLESS the size equals 1 and then it shows the element alone without the collection. I can see the utility of this *sometimes*, but looking at all of the classes for which this code would apply, I wonder. Do we want to see a Character when inspecting a single-character Symbol, String, Text? What about Interval, RunArray, WeakArray or SortedCollection when the size is one? Does it make sense to override #smartInspect in these classes to do the normal #inspect in all cases? Or is it time to consider the end (or making "smart" the option way down at the bottom and make the top item "basic" or normal)?

Cheers,
Bob





More information about the Squeak-dev mailing list