% -*- mode: latex; -*- mustache tags:  
\ifx\wholebook\relax\else

	\documentclass[10pt,twoside,english]{root/support/latex/sbabook/sbabook}
  \usepackage{import}
  \subimport{root/support/latex/}{common.tex}

  \hypersetup{pdfinfo = {
    Title = {{Pharo Mooc}},
    Author = {},
    Keywords = {pharo, smalltalk}}}
  \begin{document}
\fi

\chapter{Expressions and Messages}
This exercise is about reading and understanding Pharo expressions, and differentiating between different
types of messages and receivers.

Note that in the expressions you will be asked to read and executed, you
can assume that the implementation of methods generally corresponds to what their message names imply (i.e., \textcode{2 + 2 = 4}).

In addition, most of the expressions we use in the exercises are expressions that you can execute in Pharo, so do not hesitate. 
\subsection{Exercise: Literal objects}
What kind of object does the following literal expressions refer to?

\begin{displaycode}{smalltalk}
'Hello, Dave'
\end{displaycode}

\begin{displaycode}{smalltalk}
1.3
\end{displaycode}

\begin{displaycode}{smalltalk}
#node1
\end{displaycode}

\begin{displaycode}{smalltalk}
#(2 33 4)
\end{displaycode}

\begin{displaycode}{smalltalk}
[ :each | each scale: 1.5 ]
\end{displaycode}

\begin{displaycode}{smalltalk}
$A 
\end{displaycode}

\begin{displaycode}{smalltalk}
true
\end{displaycode}

\begin{displaycode}{smalltalk}
1
\end{displaycode}
\section{Exercise: Messages}
For each of the expressions below, fill in the answers:

\begin{itemize}
\item What is the receiver object?
\item What is the message selector?
\item What is/are the argument (s)?
\item What is the result returned by this expression execution?
\end{itemize}

\begin{displaycode}{smalltalk}
3 + 4
\end{displaycode}

\begin{displaycode}{smalltalk}
Date today
\end{displaycode}

\begin{displaycode}{smalltalk}
anArray at: 1 put: 'hello'
\end{displaycode}

\begin{displaycode}{smalltalk}
anArray at: i 
\end{displaycode}

\begin{displaycode}{smalltalk}
#(2 33 -4 67) collect: [ :each | each abs ]
\end{displaycode}

\begin{displaycode}{smalltalk}
25 @ 50
\end{displaycode}

\begin{displaycode}{smalltalk}
SmallInteger maxVal
\end{displaycode}

\begin{displaycode}{smalltalk}
#(a b c d e f) includesAll: #(f d b)
\end{displaycode}

\begin{displaycode}{smalltalk}
true | false
\end{displaycode}

\begin{displaycode}{smalltalk}
Point selectors
\end{displaycode}
\subsection{Exercise: Scope}
\begin{itemize}
\item What can one assume about a variable named \textcode{Transferator}?
\end{itemize}

\begin{itemize}
\item What can one assume about a variable named \textcode{rectangle}?
\end{itemize}


\ifx\wholebook\relax\else
\end{document}
\fi