This section describes the basics of Small, as compiled and interpreted with Embryo.

This summary assumes that you are familar with C. For a full list of differences between C and Small, again, see the full documentation.\hypertarget{Small_Page_Small_Variables_Section}{}\section{Variables}\label{Small_Page_Small_Variables_Section}
\hypertarget{Small_Page_Small_Type_Subsection}{}\subsection{Types}\label{Small_Page_Small_Type_Subsection}
There is only one type, known as the \char`\"{}cell\char`\"{}, which can hold an integer.\hypertarget{Small_Page_Small_Scope_Subsection}{}\subsection{Scope}\label{Small_Page_Small_Scope_Subsection}
The scope and usage of a variable depends on its declaration.

\begin{DoxyItemize}
\item A local variable is normally declared with the {\ttfamily new} keyword. E.\+g. 
\begin{DoxyCode}
\textcolor{keyword}{new} variable 
\end{DoxyCode}
 \item A static function variable is defined within a function with the {\ttfamily static} keyword. \item A global static variable is one that is only available within the file it was declared in. Again, use the {\ttfamily static} keyword, but outside of any function. \item A stock variable is one that may not be compiled into a program if it is not used. It is declared using {\ttfamily stock}. \item A public variable is one that can be read by the host program using embryo\+\_\+program\+\_\+variable\+\_\+find. It is declared using {\ttfamily public} keyword.\end{DoxyItemize}
Remember that the keywords above are to be used on their own. That is, for example\+:
\begin{DoxyCode}
\textcolor{keyword}{public} testvar 
\end{DoxyCode}
 not\+: 
\begin{DoxyCode}
\textcolor{keyword}{new} \textcolor{keyword}{public} testvar 
\end{DoxyCode}
\hypertarget{Small_Page_Small_Constants_Subsection}{}\subsection{Constants}\label{Small_Page_Small_Constants_Subsection}
You can declare constants in two ways\+: \begin{DoxyItemize}
\item Using the preprocessor macro {\ttfamily \#define}. \item By inserting {\ttfamily const} between the keyword and variable name of a variable declaration. For example, to declare the variable {\ttfamily var1} constant, you type
\begin{DoxyCode}
\textcolor{keyword}{new} \textcolor{keyword}{const} var1 = 2 
\end{DoxyCode}
 Now {\ttfamily var1} cannot be changed.\end{DoxyItemize}
\hypertarget{Small_Page_Small_Arrays_Subsection}{}\subsection{Arrays}\label{Small_Page_Small_Arrays_Subsection}
To declare an array, append square brackets to the end of the variable name. The following examples show how to declare arrays. Note the use of the ellipsis operator, which bases the array based on the last two declared values\+:


\begin{DoxyCode}
\textcolor{keyword}{new} msg[] = \textcolor{stringliteral}{"A message."}
\textcolor{keyword}{new} ints[] = \{1, 3, 4\}
\textcolor{keyword}{new} ints2[20] = \{1, 3\}         \textcolor{comment}{// All other elements 0.}
\textcolor{keyword}{new} ints3[10] = \{1, ... \}      \textcolor{comment}{// All elements = 1}
\textcolor{keyword}{new} ints4[10] = \{10, 20, ... \} \textcolor{comment}{// Elements = 10 -> 100.}
                               \textcolor{comment}{// The difference can be negative.}
\textcolor{keyword}{new} ints5[3][3] = \{\{1, 2, 3\}, \{4, 5, 6\}, \{7, 8, 9\}\}
\end{DoxyCode}


\begin{DoxyNote}{Note}
Array initialisers need to be constant.
\end{DoxyNote}
\hypertarget{Small_Page_Small_Func_Calls_Section}{}\section{Function Calls}\label{Small_Page_Small_Func_Calls_Section}
A typical function declaration is as follows\+:


\begin{DoxyCode}
testfunc(param) \{
  \textcolor{comment}{// Do something ...}
  \textcolor{comment}{// over a couple of lines.}
\}
\end{DoxyCode}


You can pass by reference. That is, the parameter you pass is changed outside of the function. For example\+:


\begin{DoxyCode}
testfunc(&param) \{
  param = 10
  \textcolor{comment}{// The passed variable will be set to 10 outside of the function.}
\}
\end{DoxyCode}


To pass an array\+:


\begin{DoxyCode}
testfunc(param[]) \{
  \textcolor{comment}{// Do something to the array}
\}
\end{DoxyCode}


\begin{DoxyNote}{Note}
Arrays are passed by reference.
\end{DoxyNote}
\hypertarget{Small_Page_Small_Control_Subsection}{}\section{Control Structures.}\label{Small_Page_Small_Control_Subsection}
Small has the following control structures, which similar to their C counterparts\+: \begin{DoxyItemize}
\item 
\begin{DoxyCode}
\textcolor{keywordflow}{if} (expression) statement1 \textcolor{keywordflow}{else} statement2 
\end{DoxyCode}
 \item 
\begin{DoxyCode}
 \textcolor{keywordflow}{switch} (expression) \{
  \textcolor{keywordflow}{case} 0:
    statement1 \textcolor{comment}{// Can only be one statement.  Look Ma, no breaks!}
  \textcolor{keywordflow}{case} 1..3:   \textcolor{comment}{// For values between 1 and 3 inclusive.}
    statement2
  \textcolor{keywordflow}{default}:     \textcolor{comment}{// Optional}
    statement3
\}
\end{DoxyCode}
 \item 
\begin{DoxyCode}
\textcolor{keywordflow}{while}(expression) statement 
\end{DoxyCode}
 \item 
\begin{DoxyCode}
\textcolor{keywordflow}{do} statement \textcolor{keywordflow}{while} (expression) 
\end{DoxyCode}
 \item 
\begin{DoxyCode}
\textcolor{keywordflow}{for} (init\_expression; before\_iter\_test\_expression; after\_iter\_expression) statement 
\end{DoxyCode}
\end{DoxyItemize}
\hypertarget{Small_Page_Small_Preprocessor_Section}{}\section{Preprocessor}\label{Small_Page_Small_Preprocessor_Section}
The following preprocessor directives are available\+: \begin{DoxyItemize}
\item 
\begin{DoxyCode}
\textcolor{preprocessor}{#assert constant\_expression }
\end{DoxyCode}
 \item 
\begin{DoxyCode}
\textcolor{preprocessor}{#define pattern replacement }
\end{DoxyCode}
 \item 
\begin{DoxyCode}
\textcolor{preprocessor}{#define pattern(%1,%2,...) replacement }
\end{DoxyCode}
 \item 
\begin{DoxyCode}
\textcolor{preprocessor}{#include filename }
\end{DoxyCode}
 \item 
\begin{DoxyCode}
\textcolor{preprocessor}{ #if constant\_expression}
  \textcolor{comment}{// Various bits of code}
\textcolor{preprocessor}{#else}
  \textcolor{comment}{// Other bits of code}
\textcolor{preprocessor}{#endif }
\end{DoxyCode}
 \item 
\begin{DoxyCode}
\textcolor{preprocessor}{#undef pattern }
\end{DoxyCode}
 \end{DoxyItemize}
