Skip to main content
Engineering LibreTexts

13.3: Browsing the System

  • Page ID
    39242
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    FAQ \(\PageIndex{1}\)

    The browser does not look like the one described in the book. What gives?

    Answer

    You are probably using an image in which the OmniBrowser is installed as the default System browser. You can change the default by clicking on the little menu icon in the top-left corner of the browser window, between the “X” and the browser label, and selecting “Choose new default browser” from the menu that appears. Select #Browser to get the plain old browser. (This preference changes the effect of the World ⊳ open . . . ⊳ system browser menu, but not what happens when you drag the Browser icon from the Tools flap.)

    FAQ \(\PageIndex{2}\)

    How do I search for a class?

    Answer

    CMD–b (browse) on the class name, or CMD–f in the category pane of the class browser.

    FAQ \(\PageIndex{3}\)

    How do I find/browse all sends to super?

    Answer

    The second solution is much faster:

    SystemNavigation default browseMethodsWithSourceString: 'super'.
    SystemNavigation default browseAllSelect: [:method | method sendsToSuper ].
    

    FAQ \(\PageIndex{4}\)

    How do I browse all super sends within a hierarchy?

    Answer

    browseSuperSends := [:aClass | SystemNavigation default
        browseMessageList: (aClass withAllSubclasses gather: [ :each |
            (each methodDict associations
                select: [ :assoc | assoc value sendsToSuper ])
                    collect: [ :assoc | MethodReference class: each selector: assoc key ] ])
        name: 'Supersends of ' , aClass name , ' and its subclasses'].
    browseSuperSends value: OrderedCollection.
    

    FAQ \(\PageIndex{5}\)

    How do I find out which new methods are introduced by a class? (I.e., not including overridden methods.)

    Answer

    Here we ask which methods are introduced by True:

    newMethods := [:aClass| aClass methodDict keys select:
        [:aMethod | (aClass superclass canUnderstand: aMethod) not ]].
    newMethods value: True −→ an IdentitySet(#asBit)
    

    FAQ \(\PageIndex{6}\)

    How do I tell which methods of a class are abstract?

    Answer

    abstractMethods :=
        [:aClass | aClass methodDict keys select:
            [:aMethod | (aClass>>aMethod) isAbstract ]].
    abstractMethods value: Collection −→ an IdentitySet(#remove:ifAbsent: #add:
        #do:)
    

    FAQ \(\PageIndex{7}\)

    How do I generate a view of the AST of an expression?

    Answer

    Load AST from squeaksource.com. Then evaluate:

    (RBParser parseExpression: '3+4') explore
    

    (Alternatively explore it.)

    FAQ \(\PageIndex{8}\)

    How do I find all the Traits in the system?

    Answer

    Smalltalk allTraits
    

    FAQ \(\PageIndex{9}\)

    How do I find which classes use traits?

    Answer

    Smalltalk allClasses select: [:each | each hasTraitComposition and: [each
        traitComposition notEmpty ]]
    

    This page titled 13.3: Browsing the System is shared under a CC BY-SA 3.0 license and was authored, remixed, and/or curated by Andrew P. Black, Stéphane Ducasse, Oscar Nierstrasz, Damien Pollet via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.