Skip to main content
Engineering LibreTexts

3.8: Chapter Summary

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

    • Squeak has (only) six reserved identifiers also called pseudo-variables: true, false, nil, self, super, and thisContext.
    • There are five kinds of literal objects: numbers (5, 2.5, 1.9e15, 2r111), characters ($a), strings ('hello'), symbols (#hello), and arrays (#('hello' #hello))
    • Strings are delimited by single quotes, comments by double quotes. To get a quote inside a string, double it.
    • Unlike strings, symbols are guaranteed to be globally unique.
    • Use #( ... ) to define a literal array. Use { ... } to define a dynamic array. Note that #(1+2) size \(\rightarrow\) 3, but {1+2} size \(\rightarrow\) 1
    • There are three kinds of messages: unary (e.g., 1 asString, Array new), binary (e.g., 3 + 4, 'hi', 'there'), and keyword (e.g., 'hi' at: 2 put: $o)
    • A cascaded message send is a sequence of messages sent to the same target, separated by semi-colons: OrderedCollection new add: #calvin; add: #hobbes; size \(\rightarrow\) 2
    • Local variables are declared with vertical bars. Use := for assignment; \(\leftarrow\) or _ will work as well but are deprecated since Squeak 3.9. |x| x:=1
    • Expressions consist of message sends, cascades and assignments, possibly grouped with parentheses. Statements are expressions separated by periods.
    • Block closures are expressions enclosed in square brackets. Blocks may take arguments and can contain temporary variables. The expressions in the block are not evaluated until you send the block a value... message with the correct number of arguments. [:x|x+2]value:4 \(\rightarrow\) 6.
    • There is no dedicated syntax for control constructs, just messages that conditionally evaluate blocks. (Smalltalk includes: Class) ifTrue: [ Transcript show: Class superclass ]

    This page titled 3.8: Chapter Summary 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.