Skip to main content
Engineering LibreTexts

1.5: Keyboard Shortcuts

  • Page ID
    36340
  • \( \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}}\)

    If you want to evaluate an expression, you do not always have to bring up the yellow-button menu. Instead, you can use keyboard shortcuts.

    “Doing” an expression.
    Figure \(\PageIndex{1}\): “Doing” an expression.

    These are the parenthesized expressions in the menu. Depending on your platform, you may have to press one of the modifier keys (control, alt, command, or meta). (We will indicate these generically as CMD–key.)

    \(\bigstar\) Evaluate the expression in the workspace again, but using the keyboard shortcut: CMD–d.

    In addition to do it, you will have noticed print it, inspect it and explore it. Let’s have a quick look at each of these.

    \(\bigstar\) Type the expression 3 + 4 into the workspace. Now do it with the keyboard shortcut.

    Do not be surprised if you saw nothing happen! What you just did is send the message + with argument 4 to the number 3. Normally the result 7 will have been computed and returned to you, but since the workspace did not know what to do with this answer, it simply threw the answer away. If you want to see the result, you should print it instead. print it actually compiles the expression, executes it, sends the message printString to the result, and displays the resulting string.

    \(\bigstar\) Select 3+4 and print it (CMD–p).

    This time we see the result we expect (Figure \(\PageIndex{2}\)).

    “Print it” rather than “do it”.
    Figure \(\PageIndex{2}\): “Print it” rather than “do it”.
    3+4 → 7
    

    We use the notation \(\rightarrow\) as a convention in this book to indicate that a particular Squeak expression yields a given result when you print it.

    \(\bigstar\) Delete the highlighted text “7” (Squeak should have selected it for you, so you can just press the delete key). Select 3+4 again and this time inspect it (CMD–i).

    Now you should see a new window, called an inspector, with the heading SmallInteger: 7 (Figure \(\PageIndex{3}\)). The inspector is an extremely useful tool that will allow you to browse and interact with any object in the system. The title tells us that 7 is an instance of the class SmallInteger. The left panel allows us to browse the instance variables of an object, the values of which are shown in the right panel. The bottom panel can be used to write expressions to send messages to the object.

    Inspecting an object.
    Figure \(\PageIndex{3}\): Inspecting an object.

    \(\bigstar\) Type self squared in the bottom panel of the inspector on 7 and print it.

    \(\bigstar\) Close the inspector. Type the expression Object in a workspace and this time explore it (CMD–I, uppercased i).

    This time you should see a window labelled Object containing the text root: Object. Click on the triangle to open it up (Figure \(\PageIndex{4}\)).

    Exploring an object.
    Figure \(\PageIndex{4}\): Exploring an object.

    The explorer is similar to the inspector, but it offers a tree view of a complex object. In this case the object we are looking at is the Object class. We can see directly all the information stored in this class, and we can easily navigate to all its parts.


    This page titled 1.5: Keyboard Shortcuts 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.