

% add the PATH to retrieve cls and sty beamer styles files
\makeatletter
\providecommand*{\input@path}{}
\edef\input@path{{../../support/beamer/}\input@path}% prepend
\makeatother

% \documentclass{pharoslides}
% \documentclass[aspectratio=169]{pharoslides} % format 16/9
\documentclass[withvideo]{pharoslides} % format 16/9 + incrustation video

\graphicspath{{./figures/}{../}{../../support/beamer/imgs/}}

%Information to be included in the title page:
\title{Variable Size Objects}
\subtitle{}
\author{Damien Cassou, Stéphane Ducasse and Luc Fabresse}
\institute{http://stephane.ducasse.free.fr}
\date{}
\slidesid{W7S02}

\begin{document}

\frame[plain]{\titlepage}



\begin{frame}[fragile]

\frametitle{Variable Size Instances?}

\begin{listing}{}
Array new: 10
> #(nil nil nil nil nil nil nil nil nil nil)
\end{listing}

\begin{listing}{}
Array new: 5
> #(nil nil nil nil nil)
\end{listing}

Yes arrays can have different sizes
\end{frame}



\begin{frame}[fragile]

\frametitle{What You Will Learn}

\begin{itemize}
\item How to define variable size objects?
\item How to instantiate and access variable size objects?
\end{itemize}
\end{frame}



\begin{frame}[fragile]

\frametitle{Roadmap}

\begin{itemize}
\item \textbf{How to define variable size objects?}
\item How to instantiate and access variable size objects?
\end{itemize}
\end{frame}



\begin{frame}[fragile]

\frametitle{Variable Class Definition}

Use message \code{variableSubclass:} instead of \code{subclass:}

Example

\begin{listing}{}
ArrayedCollection variableSubclass: #Array
	instanceVariableNames: ''
	classVariableNames: ''
	package: 'Collections-Sequenceable'
\end{listing}
\end{frame}



\begin{frame}[fragile]

\frametitle{Example Variable Class}

Example

\begin{listing}{}
Object variableSubclass: #StrangePoint
        instanceVariableNames: 'x y'
        classVariableNames: ''
        package: 'Collections-Sequenceable'
\end{listing}

\begin{itemize}
\item Instances of a variable class have a variable size (indexed) zone after named variables
\item Only one indexed instance variable per class (always the last one)
\end{itemize}
\end{frame}



\begin{frame}[fragile]

\frametitle{Roadmap}

\begin{itemize}
\item How to define variable size objects?
\item \textbf{How to instantiate and access variable size objects?}
\end{itemize}
\end{frame}



\begin{frame}[fragile]

\frametitle{Variable Class Instantiation and Index Access}

\begin{itemize}
\item Create instances with \code{new: max}
\item Access indexed values with \code{at:} and \code{at:put:}
\item First element starts at index 1
\item \code{size} returns the number of indexed instance variables
\end{itemize}

\begin{listing}{}
| a |
a := Array new: 4.
a at: 2 put: 'lulu'.
a at: 1
> nil
a at: 2 
> 'lulu'
\end{listing}
\end{frame}



\begin{frame}[fragile]

\frametitle{Classes with Different Shape}

\begin{itemize}
\item Classes with named instance variables 
\begin{itemize}
\item \code{Counter} has an instance variable named \code{count}
\end{itemize}

\item Classes with a variable/indexed instance variable
\begin{itemize}
\item \code{Array} has only an indexed instance variable
\end{itemize}

\item Classes with some named instance variables \textbf{and} one indexed instance variable
\end{itemize}
\end{frame}



\begin{frame}[fragile]

\frametitle{Refining the Variable Part}

\begin{tabular}{lllll}
\toprule
\textbf{Indexed} & \textbf{Named} & \textbf{Definition Method} & \textbf{Examples} \\
\midrule
No & Yes & \#subclass:... & Color &  \\
Yes & No & \#variableSubclass: & AdditionalMethodState &  \\
Yes & No & \#variableByteSubclass: & ByteString &  \\
Yes & No & \#variableWordSubclass: & Bitmap &  \\
\bottomrule
\end{tabular}

Some methods related to class types: \code{isPointers}, \code{isBits}, \code{isBytes}, \code{isFixed}, \code{isVariable}
\end{frame}



\begin{frame}[fragile]

\frametitle{Constraints}

\begin{itemize}
\item Classes defined using \code{subclass:} can have any kind of subclasses
\item Classes defined using \code{variableSubclass:} can only have \code{variableSubclass:} subclasses
\end{itemize}
\end{frame}



\begin{frame}[fragile]

\frametitle{What You Should Know}

\begin{itemize}
\item How to define variable size objects?
\begin{itemize}
\item define a \code{variableSubclass:} with an indexed instance variable 
\end{itemize}

\item How to instantiate variable size objects?
\begin{itemize}
\item use \code{new:} 
\item use \code{at:} and \code{at:put:} to access indexed values
\end{itemize}

\end{itemize}
\end{frame}




% \setlength{\textwidth}{\originaltextwidth}
\setbeamertemplate{background canvas}{\insertBorderForHandout}

\begin{frame}[plain]

\begin{minipage}{\originaltextwidth}
\centering
\large


\vspace{2em}

A course by

\vspace{1em}

\hspace{-20px}\includegraphics[height=32px]{inriaLogo}\hspace{3em}\raisebox{7px}{and}\hspace{3em}\raisebox{-6px}{\includegraphics[height=30px]{logoutop}}

\vspace{2em}

in collaboration with

\vspace{1em}

\includegraphics[height=40px]{unisciellogo}\hskip 1.5em%
\raisebox{5px}{\includegraphics[height=30px]{unitlogo}}\hskip 2em%
\raisebox{8px}{\includegraphics[height=24px]{univLilleLogo}}\hskip 2em%
\raisebox{3px}{\includegraphics[height=29px]{logo-IMT}}\hskip 2em%
\raisebox{1px}{\includegraphics[height=32px]{minesDouaiLogo}}

\vspace{2.5em}

\includegraphics[width=50px]{by-nc-nd} \tiny \hskip 0.5em \raisebox{5px}{Inria 2016}

\medskip

\tiny
Except where otherwise noted, this work is licensed under CC BY-NC-ND 3.0 France

\url{https://creativecommons.org/licenses/by-nc-nd/3.0/fr/} 

\end{minipage}
\end{frame}

\end{document}

%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:
