Skip to content

Commit

Permalink
Merge branch 'master' into extract-book
Browse files Browse the repository at this point in the history
  • Loading branch information
LinqLover authored Nov 19, 2024
2 parents 44bd868 + dee43e9 commit c26e3ab
Show file tree
Hide file tree
Showing 21 changed files with 122 additions and 90 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
matrix:
smalltalk: ${{ fromJson(needs.args.outputs.squeak-versions) }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: hpi-swa/setup-smalltalkCI@v1
with:
smalltalk-image: Squeak64-${{ matrix.smalltalk }}
Expand All @@ -74,7 +74,7 @@ jobs:
matrix:
smalltalk: ${{ fromJson(needs.args.outputs.squeak-versions) }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: hpi-swa/setup-smalltalkCI@v1
with:
smalltalk-image: Squeak64-${{ matrix.smalltalk }}
Expand All @@ -85,7 +85,7 @@ jobs:
name: 📄 Collect listings from SmalltalkSources
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- run: make listings
- name: 💾 Store listings
uses: actions/upload-artifact@master
Expand All @@ -101,7 +101,7 @@ jobs:
matrix:
smalltalk: ${{ fromJson(needs.args.outputs.squeak-versions) }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: hpi-swa/setup-smalltalkCI@v1
with:
smalltalk-image: Squeak64-${{ matrix.smalltalk }}
Expand Down
22 changes: 11 additions & 11 deletions BasicClasses/BasicClasses.tex
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ \section{Object}
%-----------------------------------------------------------------
\subsection{Printing}
Every object in Smalltalk can return a printed form of itself.
You can select any expression in a workspace and select the \menu{print it} menu item:
You can select any expression in a workspace and select the \menu{print it} menu item: \index{print it}
This executes the expression and asks the returned object to print itself.
In fact, this sends the message \ct{printString} to the returned object.
The method \mthind{Object}{printString}, which is a \ind{template method}, at its core sends the message \mthind{Object}{printOn:} to its receiver.
Expand Down Expand Up @@ -951,9 +951,9 @@ \section{Exceptions}
Using \ct{pass}, you can design your exception handlers to only handle some exceptions based on their state and pass all others to the next handler:
\begin{code}{NB: CANNOT TEST}
[self downloadData]
on: ConnectionRefused do: [:ex |
self cache at: ex host ifAbsent: [ex pass]].
[self downloadData]
on: ConnectionRefused do: [:ex |
self cache at: ex host ifAbsent: [ex pass]].
\end{code}
This example tries to download some data from a server, but if the connection is refused, it will try to fallback to an offline cache.
Expand All @@ -968,11 +968,11 @@ \section{Exceptions}
For instance, most dialogs in \sq signal a \clsind{ProvideAnswerNotification} before they show up to the user, which allows the code that eventually triggered the dialog to automatically answer the question:
\begin{code}{NB: CANNOT TEST}
Morph new exportAsPNG. --> "a file dialog opens for entering a file name"
Morph new exportAsPNG. --> "a file dialog opens for entering a file name"
[Morph new exportAsPNG]
on: ProvideAnswerNotification
do: [:ex | ex resume: 'myMorph.png']. --> "no dialog opens, the file is saved as 'myMorph.png'"
[Morph new exportAsPNG]
on: ProvideAnswerNotification
do: [:ex | ex resume: 'myMorph.png']. --> "no dialog opens, the file is saved as 'myMorph.png'"
\end{code}
Note that specifically for handling \clsindplural{ProvideAnswerNotification}, there are the more convenient methods \cmind{BlockClosure}{valueSupplyingAnswers:} and \cmind{BlockClosure}{valueSuppressingMessages:}.
Expand All @@ -986,9 +986,9 @@ \section{Exceptions}
For instance, the following would be equivalent to the first example above:
\begin{code}{@TEST}
[(-2 to:2) collect: [:i | 100 / i]]
on: ZeroDivide
do: [:ex | ex return: nil].
[(-2 to:2) collect: [:i | 100 / i]]
on: ZeroDivide
do: [:ex | ex return: nil].
\end{code}
\end{itemize}
Expand Down
12 changes: 6 additions & 6 deletions Bibliography/LatexTemplates/st80demo.tex
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ \section*{Code environments using the listings package}

%=============================================================
\subsection*{Listings environments and macros}
The code environments
The code environments

\begin{verbatim}
\begin{code}
...
...
\end{code}
\end{verbatim}
take plain, verbatim code,
Expand All @@ -39,12 +39,12 @@ \subsection*{Listings environments and macros}
true & false not & (nil isNil) ifFalse: [self halt].
y _ self size + super size.
#($a #a 'a' 1 1.0)
do: [:each | Transcript
show: (each class name);
do: [:each | Transcript
show: (each class name);
show: ' ';
show: (each printString).
{ 1 + 2 . 3 \\ 4 . 1 << 3. 2 >> 5 . 1 % 2 }.
^ x < y
^ x < y
\end{code}
QWERTY layout:
Expand All @@ -70,7 +70,7 @@ \subsection*{Listings environments and macros}
plain code and !\textbf{bolded text}!
\end{code}
% ^ $ \\ % # '
% ^ $ \\ % # '
In-line code with \verb|\ct| is typed like this \verb|\ct{1 + 2 --> 3}| and looks like this: \ct{1 + 2 --> 3}, text can follow immediately. The ``brackets'' around \verb|\ct| can be any matching pair of characters, useful if you want \ct${ and }$ in the code.
Expand Down
11 changes: 5 additions & 6 deletions Collections/Collections.tex
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ \chapter{Collections}
%\sd{Did a first pass: I should have a look at Xavier Briffault's book and at the material mentionned by andrew + lalonde book?}
%\pre{Removed the abstract, high-level, number-heavy introduction on the collection hierarchy}
%=============================================================
\section{Introduction}

To make good use of the collection classes, \st programmers need at least an overview of the wide variety of collections and their commonalities and differences.
%
Expand Down Expand Up @@ -377,17 +376,17 @@ \section{Examples of key classes}
Array withAll: #(7 3 1 3) --> #(7 3 1 3)
OrderedCollection withAll: #(7 3 1 3) --> an OrderedCollection(7 3 1 3)
SortedCollection withAll: #(7 3 1 3) --> a SortedCollection(1 3 3 7)
Set withAll: #(7 3 1 3) --> a Set(7 1 3)
Bag withAll: #(7 3 1 3) --> a Bag(7 1 3 3)
Set withAll: #(7 3 1 3) --> !\SqVersionSwitch{6.1}{a Set(1 3 7)}{a Set(7 1 3)}!
Bag withAll: #(7 3 1 3) --> !\SqVersionSwitch{6.1}{a Bag(1->1 3->2 7->1)}{a Bag(7 1 3 3)}!
\end{code}
\begin{code}{@TEST}
Array newFrom: #(7 3 1 3) --> #(7 3 1 3)
OrderedCollection newFrom: #(7 3 1 3) --> an OrderedCollection(7 3 1 3)
SortedCollection newFrom: #(7 3 1 3) --> a SortedCollection(1 3 3 7)
Set newFrom: #(7 3 1 3) --> a Set(7 1 3)
Bag newFrom: #(7 3 1 3) --> a Bag(7 1 3 3)
Dictionary newFrom: {1 -> 7 . 2 -> 3 . 3 -> 1 . 4 -> 3} --> a Dictionary(1->7 2->3 3->1 4->3 )
Set newFrom: #(7 3 1 3) --> !\SqVersionSwitch{6.1}{a Set(1 3 7)}{a Set(7 1 3)}!
Bag newFrom: #(7 3 1 3) --> !\SqVersionSwitch{6.1}{a Bag(1->1 3->2 7->1)}{a Bag(7 1 3 3)}!
Dictionary newFrom: {1 -> 7 . 2 -> 3 . 3 -> 1 . 4 -> 3} --> !\SqVersionSwitch{6.1}{a Dictionary(1->7 2->3 3->1 4->3)}{a Dictionary(1->7 2->3 3->1 4->3 )}!
\end{code}
\noindent
Note that these two methods are not identical.
Expand Down
11 changes: 7 additions & 4 deletions Environment/Environment.tex
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ \subsubsection{Browsing code}
When you are writing code you will almost certainly need at least two: one for the method that you are typing, and another to browse around the system to see what to type.
You can also open a browser on a class named by any selected text using the \short{b} keyboard shortcut.
\index{system browser!browse button}
\index{keyboard shortcuts!browse it}
\index{browse it}

\dothis{Try this: in a workspace window, type the name of a class (for instance \ct{ScaleMorph}), select it, and then press \short{b}. This trick is often useful; it works in any text window.}

Expand Down Expand Up @@ -608,6 +608,7 @@ \section{The inspector and the explorer}
\subsection{The inspector}

\dothis{As an illustration of what you can do with an \ind{inspector}, type \ct{TimeStamp now} in a workspace, and then choose \menu{inspect it} from the \ind{yellow button} menu.
\index{inspect it}
(It's not necessary to select the text before using the menu; if no text is selected, the menu operations work on the whole of the current line.
You can also type \short{i} for \menu{\textbf{i}nspect it}.)}
\clsindex{TimeStamp}
Expand Down Expand Up @@ -790,7 +791,7 @@ \subsection{The instance browser}
However, this window is more interesting as it still knows about the \ct{PluggableListMorph} for which we opened it.
Thus, we can evaluate code in the code pane.

\dothis{In the browser, open the method \ct{fullListSize} by selecting it in the list at the top right. Then, navigate to the last code line and \menu{print it} (\short{p}). You should see the result of evaluating the expression right within the code editor.}
\dothis{In the browser, open the method \ct{fullListSize} by selecting it in the list at the top right. Then, navigate to the last code line and \menu{print it} (\short{p}). \index{print it} You should see the result of evaluating the expression right within the code editor.}

\begin{ExecuteSmalltalkScript}
SBEScreenshotRecorder writeTo: './figures/instanceBrowser.png' building: [:helper |
Expand Down Expand Up @@ -1119,6 +1120,7 @@ \subsection{From the debugger to tests and back again}
StringTest >> #testSuffixFound.
StringTest >> #testSuffixNotFound.
StringTest >> #testShout.
StringTest compiledMethodAt: #testFindLiteralBooleanOrNil ifAbsent: [].
StringTest >> #testPercentEncodingJa. }
after: block].
String compile: 'suffix
Expand All @@ -1135,6 +1137,7 @@ \subsection{From the debugger to tests and back again}
.
StringTest compile: 'testShout'. "To prevent a failure from this test"
StringTest removeSelector: #testSuffixNotFound.
StringTest removeSelector: #testFindLiteralBooleanOrNil.
StringTest removeSelector: #testPercentEncodingJa. "very slow"
testRunner := TestRunner newForSuite: StringTest suite.
testRunner runAll.
Expand Down Expand Up @@ -1273,7 +1276,7 @@ \section{The process browser}
\figref{processBrowser} shows a screenshot.
The top-left pane lists all of the processes in \sq, in priority order, from the timer interrupt watcher at priority 80 to the idle process at priority 10.
Of course, on a uniprocessor, when you look which program is running, the only process that can be running is the UI process, as it is currently displaying the information to you; all of the other will be waiting for some kind of event.
By default, the display of processes is static; it can be updated using the \ind{yellow button} menu, which also provides an option to \menu{turn on auto-update (a)}
By default, the display of processes is static; it can be updated using the \ind{yellow button} menu, which also provides an option to \menu{turn on auto-update (a)}.
If you select a process in the top-left pane, its stack trace is displayed in the top-right pane, just as with the debugger.
If you select a stack frame, the corresponding method is displayed in the bottom pane.
Expand Down Expand Up @@ -1407,7 +1410,7 @@ \section{Other interesting tools}
\begin{minipage}[t]{0.48\textwidth}
\ifluluelse
{\includegraphics[width=\textwidth]{SpaceTally}}
{\includegraphics[scale=0.7]{exploreWithLabel: 'SpaceTally'}}
{\includegraphics[scale=0.7]{SpaceTally}}
\label{fig:SpaceTally}
\end{minipage}
\caption{A time profiler (left) and a space tally (right).}
Expand Down
6 changes: 3 additions & 3 deletions FAQ/FAQ.tex
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ \section{Browsing the system}
\end{faq}
\answer
\short{b} (browse) on the class name, \short{f} in the category pane of the class browser, or the global search on the top right of the world.
\index{keyboard shortcuts!browse it}
\index{browse it}
\index{keyboard shortcuts!find ...}

\begin{faq}
Expand Down Expand Up @@ -302,7 +302,7 @@ \section{Using Monticello and SqueakSource}
\end{faq}
\answer
\begin{enumerate}
\item Find the project you want in \url{squeaksource.com}
\item Find the project you want in \url{https://squeaksource.com}
\item Copy the registration code snippet
\item Select \menu{World docking bar~\go{} Tools~\go{} Monticello browser}
\item Select \menu{+Repository~\go{} HTTP}
Expand All @@ -316,7 +316,7 @@ \section{Using Monticello and SqueakSource}
\end{faq}
\answer
\begin{enumerate}
\item Go to \url{squeaksource.com}
\item Go to \url{https://squeaksource.com}
\item Register yourself as a new member
\item Register a project (name = category)
\item Copy the Registration code snippet
Expand Down
23 changes: 12 additions & 11 deletions FirstApp/FirstApp.tex
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ \section{Creating a new class category}

We have already seen the \ind{system browser} in \charef{quick}, where we learned how to navigate to classes and methods, and saw how to define new methods.
Now we will see how to create system categories and classes.
\seeindex{system category}{category}
\seeindex{system category}{category, system}
\seeindex{class category}{system category}
\index{category!creating}

Expand Down Expand Up @@ -133,16 +133,16 @@ \section{Defining the class SBECell}

As yet there are of course no classes in the new category.
However, the main editing pane displays a template to make it easy to create a new class (see \figref{classTemplate}).
This template shows us a \st expression that sends a message to a class called \ct{Object}, asking it to create a subclass called \ct{NameOfSubClass}.
This template shows us a \st expression that sends a message to a class called \ct{Object}, asking it to create a subclass called \ct{NameOfSubclass}.
The new class has no variables and should belong to the category \scat{SBE-Quinto}.
We now modify the template to create the class that we want.

\dothis{Modify the class creation template as follows:}
\begin{itemize}
\begin{enumerate}
\item Replace \clsind{Object} by \clsind{SimpleSwitchMorph}.
\item Replace \ct{NameOfSubClass} by \clsind{SBECell}.
\item Replace \ct{NameOfSubclass} by \clsind{SBECell}.
\item Add \ct{mouseAction} to the list of instance variables.
\end{itemize}
\end{enumerate}
The result should look like \clsref{firstClassDef}.

\begin{classdef}[firstClassDef]{Defining the class \ct| SBECell|.}
Expand Down Expand Up @@ -289,7 +289,8 @@ \section{Inspecting an object}
You can test the effect of the code you have written by creating a new \ct{SBECell} object and inspecting it.

\dothis{Open a workspace.
Type the expression \ct{SBECell new} and \menu{inspect it}.}
Type the expression \ct{SBECell new} and \menu{inspect it}.
\index{inspect it}}

\begin{ExecuteSmalltalkScript}
SBEScreenshotRecorder writeTo: './figures/SBECellInspector.png' frame: #morphs building: [:helper |
Expand Down Expand Up @@ -767,7 +768,7 @@ \section{Saving and sharing Smalltalk code}
The yellow-button menu in the System Categories pane will give you the option to file out the whole of category \scat{SBE-Quinto}.
The resulting file is more or less human-readable, but is really intended for computers, not humans.
You can email this file to your friends, and they can file it into their own \squeak images using drag-and-drop.
\seeindex{saving code}{categories}
\seeindex{saving code}{file, filing out}
\seeindex{category!filing out}{file, filing out}
\seeindex{class!filing out}{file, filing out}
\seeindex{method!filing out}{file, filing out}
Expand All @@ -786,7 +787,7 @@ \section{Saving and sharing Smalltalk code}

\subsection{Monticello packages}
Although fileouts are a convenient way of making a snapshot of the code you have written, they do not work well for long-running projects.
Just as most open-source projects find it much more convenient to maintain their code in a repository using \ind{Git}\footnote{\url{www.git-scm.com}} or \ind{Mercurial}\footnote{\url{www.mercurial-scm.org}}, so \squeak programmers find it more convenient to manage their code using \ind{Monticello} packages.
Just as most open-source projects find it much more convenient to maintain their code in a repository using \ind{Git}\footnote{\url{https://www.git-scm.com}} or \ind{Mercurial}\footnote{\url{https://www.mercurial-scm.org}}, so \squeak programmers find it more convenient to manage their code using \ind{Monticello} packages.
These packages are represented as files with names ending in \ct{.mcz}; they are actually zip-compressed bundles that contain the complete code of your \ind{package}.

Using the Monticello package browser, you can save packages to repositories on various types of servers, including FTP and HTTP servers; you can also just write the packages to a repository in a local file system directory.
Expand Down Expand Up @@ -833,12 +834,12 @@ \subsection{Saving and loading code with Monticello}

\subsection{\ind{SqueakSource}: a sharing platform for Monticello}
We think that the best way to save your code and share it is to create an account for your project on a SqueakSource server.
SqueakSource is similar to GitHub\footnote{\url{www.github.com}}:
SqueakSource is similar to GitHub\footnote{\url{https://www.github.com}}:
It is a web front-end to an HTTP Monticello server that lets you manage your projects.
There is a public SqueakSource server at \url{http://www.squeaksource.com}, and a copy of the code related to our game is stored there at \sbeSqueaksourceUrl.
There is a public SqueakSource server at \url{https://www.squeaksource.com}, and a copy of the code related to our game is stored there at \sbeSqueaksourceUrl.
You can look at this project with a web browser, but it's a lot more productive to do so from inside \squeak, using the Monticello browser, which lets you manage your packages.

\dothis{Open a web browser to \url{www.squeaksource.com}.
\dothis{Open a web browser to \url{https://www.squeaksource.com}.
Create an account for yourself and then create (\ie ``register'') a project for the Quinto game.}
SqueakSource will show you the information that you should use when adding a repository using the Monticello browser.

Expand Down
2 changes: 1 addition & 1 deletion Model/Model.tex
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ \section{Everything happens by sending messages}

One of the consequences of \st's model of message sending is that it encourages a style in which objects tend to have very small methods and delegate tasks to other objects, rather than implementing huge, procedural methods that assume too much responsibility.
Joseph Pelrine expresses this principle succinctly as follows:
\important{Don not do anything that you can push off onto someone else.}
\important{Do not do anything that you can push off onto someone else.}
\index{Pelrine, Joseph}
\ab{Citation?}
\on{sorry, just personal communication and my own lecture notes!}
Expand Down
8 changes: 4 additions & 4 deletions Morphic/Morphic.tex
Original file line number Diff line number Diff line change
Expand Up @@ -659,10 +659,10 @@ \subsection{Morphic animations}
\dothis{Add the following code to \mthref{handleKeystroke}:}

\begin{code}{}
keyValue = $+ asciiValue
ifTrue: [self startStepping].
keyValue = $- asciiValue
ifTrue: [self stopStepping].
keyValue = $+ asciiValue
ifTrue: [self startStepping].
keyValue = $- asciiValue
ifTrue: [self stopStepping].
\end{code}

% \on{You can also \menu{debug~\go{} inspect morph} and evaluate: \ct{self currentWorld startStepping: self}.}
Expand Down
Loading

0 comments on commit c26e3ab

Please sign in to comment.