Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > bac5fede712203208ef64743259eb319 > files > 8

embryo-devel-1.0.0-2.fc15.i686.rpm

<html>
<head>
    <title>Embryo: Brief Introduction to Small</title>
    <meta http-equiv="content-type" content="text/html;charset=UTF-8">
    <meta name="author" content="Andres Blanc" >
    
    <link rel="icon" href="img/favicon.png" type="image/x-icon">
    <link rel="shortcut icon" href="img/favicon.png" type="image/x-icon">
    <link rel="icon" href="img/favicon.png" type="image/ico">
    <link rel="shortcut icon" href="img/favicon.png" type="image/ico">

    <link rel="stylesheet" type="text/css" media="screen" href="e.css">
    <link rel="stylesheet" type="text/css" media="screen" href="edoxy.css">
</head>

<body>

<div id="container">

<div id="header">
<div class="layout">
    
    <h1><span>Enlightenment</span></h1>
    <h2><span>Beauty at your fingertips</span></h2>

    <div class="menu-container">
        <div class="menu">
            <ul>
	        <li class="current"><a href="http://web.enlightenment.org/p.php?p=docs">Docs</a></li>
                <li><a href="http://trac.enlightenment.org/e">Tracker</a></li>
                <li><a href="http://www.enlightenment.org/p.php?p=contact">Contact</a></li>
                <li><a href="http://www.enlightenment.org/p.php?p=contribute">Contribute</a></li>
                <li><a href="http://www.enlightenment.org/p.php?p=support">Support</a></li>
                <li><a href="http://www.enlightenment.org/p.php?p=download">Download</a></li>
                <li><a href="http://www.enlightenment.org/p.php?p=about">About</a></li>
                <li><a href="http://www.enlightenment.org/p.php?p=news">News</a></li>
                <li><a href="http://www.enlightenment.org/">Home</a></li>
            </ul>
        </div>
    </div>

    <div class="doxytitle">
        Embryo Documentation <small>at Tue Feb 8 2011</small>
    </div>

    <div class="menu-container">
        <div class="submenu">
            <ul class="current">
                <li><a href="todo.html">Todo</a></li>
                <li><a href="files.html">Files</a></li>
                <li><a href="annotated.html">Data Structures</a></li>
                <li><a href="globals.html">Globals</a></li>
                <li><a href="modules.html">Modules</a></li>
                <li><a href="pages.html">Related Pages</a></li>
	        <li class="current"><a href="index.html">Main Page</a></li>
            </ul>
        </div>
    </div>


    <div class="clear"></div>
</div>
</div>

<div id="content">
<div class="layout">
<!-- Generated by Doxygen 1.7.3 -->
</div>
<div class="header">
  <div class="headertitle">
<h1>Brief Introduction to Small </h1>  </div>
</div>
<div class="contents">
<div class="textblock"><p>This section describes the basics of Small, as compiled and interpreted with Embryo.</p>
<p>This summary assumes that you are familar with C. For a full list of differences between C and Small, again, see the full documentation.</p>
<h2><a class="anchor" id="Small_Variables_Section"></a>
Variables</h2>
<h3><a class="anchor" id="Small_Type_Subsection"></a>
Types</h3>
<p>There is only one type, known as the "cell", which can hold an integer.</p>
<h3><a class="anchor" id="Small_Scope_Subsection"></a>
Scope</h3>
<p>The scope and usage of a variable depends on its declaration.</p>
<ul>
<li>A local variable is normally declared with the <code>new</code> keyword. E.g. <div class="fragment"><pre class="fragment"> <span class="keyword">new</span> variable 
</pre></div> </li>
<li>A static function variable is defined within a function with the <code>static</code> keyword. </li>
<li>A global static variable is one that is only available within the file it was declared in. Again, use the <code>static</code> keyword, but outside of any function. </li>
<li>A stock variable is one that may not be compiled into a program if it is not used. It is declared using <code>stock</code>. </li>
<li>A public variable is one that can be read by the host program using <a class="el" href="group__Embryo__Public__Variable__Group.html#ga9714d1cbd46b3b0315a71c23413ad921">embryo_program_variable_find</a>. It is declared using <code>public</code> keyword.</li>
</ul>
<p>Remember that the keywords above are to be used on their own. That is, for example: </p>
<div class="fragment"><pre class="fragment"> <span class="keyword">public</span> testvar 
</pre></div><p> not: </p>
<div class="fragment"><pre class="fragment"> <span class="keyword">new</span> <span class="keyword">public</span> testvar 
</pre></div><h3><a class="anchor" id="Small_Constants_Subsection"></a>
Constants</h3>
<p>You can declare constants in two ways: </p>
<ul>
<li>Using the preprocessor macro <code>#define</code>. </li>
<li>By inserting <code>const</code> between the keyword and variable name of a variable declaration. For example, to declare the variable <code>var1</code> constant, you type <div class="fragment"><pre class="fragment"> <span class="keyword">new</span> <span class="keyword">const</span> var1 = 2 
</pre></div> Now <code>var1</code> cannot be changed.</li>
</ul>
<h3><a class="anchor" id="Small_Arrays_Subsection"></a>
Arrays</h3>
<p>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:</p>
<div class="fragment"><pre class="fragment"><span class="keyword">new</span> msg[] = <span class="stringliteral">&quot;A message.&quot;</span>
<span class="keyword">new</span> ints[] = {1, 3, 4}
<span class="keyword">new</span> ints2[20] = {1, 3}         <span class="comment">// All other elements 0.</span>
<span class="keyword">new</span> ints3[10] = {1, ... }      <span class="comment">// All elements = 1</span>
<span class="keyword">new</span> ints4[10] = {10, 20, ... } <span class="comment">// Elements = 10 -&gt; 100.</span>
                               <span class="comment">// The difference can be negative.</span>
<span class="keyword">new</span> ints5[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}
</pre></div><dl class="note"><dt><b>Note:</b></dt><dd>Array initialisers need to be constant.</dd></dl>
<h2><a class="anchor" id="Small_Func_Calls_Section"></a>
Function Calls</h2>
<p>A typical function declaration is as follows:</p>
<div class="fragment"><pre class="fragment">testfunc(param) {
  <span class="comment">// Do something ...</span>
  <span class="comment">// over a couple of lines.</span>
}
</pre></div><p>You can pass by reference. That is, the parameter you pass is changed outside of the function. For example:</p>
<div class="fragment"><pre class="fragment">testfunc(&amp;param) {
  param = 10
  <span class="comment">// The passed variable will be set to 10 outside of the function.</span>
}
</pre></div><p>To pass an array:</p>
<div class="fragment"><pre class="fragment">testfunc(param[]) {
  <span class="comment">// Do something to the array</span>
}
</pre></div><dl class="note"><dt><b>Note:</b></dt><dd>Arrays are passed by reference.</dd></dl>
<h2><a class="anchor" id="Small_Control_Subsection"></a>
Control Structures.</h2>
<p>Small has the following control structures, which similar to their C counterparts: </p>
<ul>
<li><div class="fragment"><pre class="fragment"> <span class="keywordflow">if</span> (expression) statement1 <span class="keywordflow">else</span> statement2 
</pre></div> </li>
<li><div class="fragment"><pre class="fragment"> <span class="keywordflow">switch</span> (expression) {
  <span class="keywordflow">case</span> 0:
    statement1 <span class="comment">// Can only be one statement.  Look Ma, no breaks!</span>
  <span class="keywordflow">case</span> 1..3:   <span class="comment">// For values between 1 and 3 inclusive.</span>
    statement2
  <span class="keywordflow">default</span>:     <span class="comment">// Optional</span>
    statement3
}
</pre></div> </li>
<li><div class="fragment"><pre class="fragment"> <span class="keywordflow">while</span>(expression) statement 
</pre></div> </li>
<li><div class="fragment"><pre class="fragment"> <span class="keywordflow">do</span> statement <span class="keywordflow">while</span> (expression) 
</pre></div> </li>
<li><div class="fragment"><pre class="fragment"> <span class="keywordflow">for</span> (init_expression; before_iter_test_expression; after_iter_expression) statement 
</pre></div></li>
</ul>
<h2><a class="anchor" id="Small_Preprocessor_Section"></a>
Preprocessor</h2>
<p>The following preprocessor directives are available: </p>
<ul>
<li><div class="fragment"><pre class="fragment"><span class="preprocessor"> #assert constant_expression </span>
</pre></div> </li>
<li><div class="fragment"><pre class="fragment"><span class="preprocessor"> #define pattern replacement </span>
</pre></div> </li>
<li><div class="fragment"><pre class="fragment"><span class="preprocessor"> #define pattern(%1,%2,...) replacement </span>
</pre></div> </li>
<li><div class="fragment"><pre class="fragment"><span class="preprocessor"> #include filename </span>
</pre></div> </li>
<li><div class="fragment"><pre class="fragment"><span class="preprocessor"> #if constant_expression</span>
<span class="preprocessor"></span>  <span class="comment">// Various bits of code</span>
<span class="preprocessor">#else</span>
<span class="preprocessor"></span>  <span class="comment">// Other bits of code</span>
<span class="preprocessor">#endif </span>
</pre></div> </li>
<li><div class="fragment"><pre class="fragment"><span class="preprocessor"> #undef pattern </span>
</pre></div> </li>
</ul>
</div></div>
 
 <div id="push"></div>
 </div> <!-- #content -->
  </div> <!-- .layout -->
 
 </div> <!-- #container -->
 
 
  <div id="footer">
    <table><tr>
      <td class="poweredby"><img src="doxygen.png"></td>
      <td class="copyright">Copyright &copy;2011 Enlightenment</td>
      <td class="generated">Docs generated Tue Feb 8 2011 18:11:42</td>
    </tr></table>
  </div>


</body>
</html>