From 9bff16bb74ddf814a53c3152bed16d6c2f0dfa5d Mon Sep 17 00:00:00 2001
From: ocelot-inc <pgulutzan@ocelot.ca>
Date: Sun, 7 Sep 2014 10:44:24 -0600
Subject: [PATCH] moved 'writing and running lua code' to start of chapter 3

---
 doc/user/lua-and-packages.xml  | 129 --------------------------------
 doc/user/lua-tutorial.xml      |   2 +-
 doc/user/stored-procedures.xml | 131 +++++++++++++++++++++++++++++++++
 3 files changed, 132 insertions(+), 130 deletions(-)

diff --git a/doc/user/lua-and-packages.xml b/doc/user/lua-and-packages.xml
index bbd18b4bcf..5038ee1de2 100644
--- a/doc/user/lua-and-packages.xml
+++ b/doc/user/lua-and-packages.xml
@@ -21,135 +21,6 @@
     </para>
 </blockquote>
 
-<para>
-<bridgehead renderas="sect4">The "Batteries Included" Lua Software Distribution</bridgehead>
-Tarantool incorporates open-source
-precompiled packages which Tarantool's developers
-have tested for compatibility -- the "built-in" packages.
-Tarantool specializes in packages which aid
-database applications or which Tarantool's own developers
-use to make database-related tools.
-At the same time.
-Tarantool makes it easy to add new Lua packages
-from <link xlink:href=" http://luarocks.org/">LuaRocks</link> -- the "downloadable" packages.
-</para>
-
-<para>
-The included language processor is <link xlink:href="http://luajit.org/">LuaJIT</link>.
-Major "built-in" components are: fibers,
-<link xlink:href="http://msgpack.org">MsgPack</link>,
-digest, JSON, <link xlink:href="http://en.wikipedia.org/wiki/Yaml">YAML</link>,
-<link xlink:href="http://en.wikipedia.org/wiki/Inter-process_communication">IPC</link> , and box.
-</para>
-
-<para>
-LUAJIT is a processor for the entire Lua language. 
-This differs from the original Lua interpreter from
-<link xlink:href="http://www.puc-rio.br/index.html">Pontifícia Universidade Católica do Rio de Janeiro</link>
-("RIO-PUC" <link xlink:href="http://www.lua.org/">Lua</link>) 
-because the JIT stands for "Just In Time" compiling, that
-is, it can compile some Lua code into machine executable form the
-after a few executions of the code.
-The result is that some
-loops will run as quickly as an equivalent C program.
-Also some precompiled C code can be brought in using
-LuaJIT's FFI (<link xlink:href="https://en.wikipedia.org/wiki/Foreign_function_interface">Foreign Function Interface</link>).
-Examples for using FFI exist on the Internet, for example 
-<link xlink:href="https://github.com/tarantool/tarantool/blob/master/src/box/lua/tuple.lua">tuple.lua</link> on the tarantool.org site.
-</para>
-
-<para>
-LuaJIT has been compared to competitive implementations
-and found to be reliable and efficient,
-provided one takes advantage of it where <link xlink:href="http://wiki.luajit.org/Numerical-Computing-Performance-Guide">performance</link> counts. 
-</para>
-
-    <para>
-        Apart from increased performance, LuaJIT provides such
-        features as <link
-        xlink:href="http://bitop.luajit.org/">bitwise
-        operations</link> and <link xlink:href="#tonumber64">64-bit integer arithmetic.</link>
-    </para>
-
-<para>
-FIBERS are like Lua coroutines, but as <link xlink:href="http://members.chello.nl/~w.couwenberg/fibers.htm">one fiber developer</link>
-put it: "The main difference between a coroutine and a fiber
-is that a running fiber can be suspended anywhere in a call
-chain, regardless of its C and Lua call stack nesting levels."       
-</para>
-
-<para>
-MSGPACK is a relatively new way to serialize data.                    
-The point of MsgPack is that it can
-handle Lua types and C types, with structures and nesting,
-without the overhead of an SGML-style markup language.
-</para>
-
-<para>
-DIGEST is a cryptography package for CRC32, SHA, and MDA.
-Nothing new here -- except that Tarantool has made them into a
-package, so that one doesn't have to get each one of these
-things individually from the <link xlink:href="http://lua-users.org/wiki/CryptographyStuff">many that are available</link>.
-And, since Tarantool is binding with FFI rather than a traditional Lua C
-API, the routines should run faster on LuaJIT.
-</para>
-
-<para>
-JSON is a serialization format which has
-become popular in the web world. The package within
-Tarantool is derived from <link xlink:href="http://www.kyne.com.au/~mark/software/lua-cjson-manual.html">CJSON</link>
-which, according to <link xlink:href="http://lua-users.org/wiki/JsonModules">a survey</link>, 
-handles Unicode surrogate pairs and is robust when
-edge cases come up.
-</para>
-
-<para>
-YAML is short for "YAML Ain't a Markup Language". YAML is a            
-way to show data in human-readable form, without losing
-underlying information about typing, arrays, and structures.
-</para>
-
-<para>
-IPC is Inter-Process Communication.
-this is useful for implementations of task queues and long polling.
-</para>
-
-<para>
-BOX is the NoSQL DBMS that was developed by Tarantool
-and its community. Box's architecture and routines will be the
-subject of the next chapter.
-</para>
-
-<para>
-<bridgehead renderas="sect4">The Downloadable Packages</bridgehead>
-A directory of Lua Addons packages can be found on the <link xlink:href="http://lua-users.org/wiki/LuaAddons">Lua-users</link> wiki. 
-For a "managed package" system equivalent to Perl's CPAN and Ruby's RubyGems and Python's
-Eggs, one gets "rocks" (modules or packages) from <emphasis>LuaRocks</emphasis>.
-Either way, the installation requirement can be as simple as saying
-require('package-name')
-and the effect is a simple Lua table containing 
-functions and members, superficially like C/Java classes.
-</para>
-
-<para>
-There are <link xlink:href="https://rocks.moonscript.org/modules">several hundred LuaRocks packages</link> that are not built-in       
-but are reasonably easy to obtain by anyone with an Internet
-connection. Just as a sampling: ...
-<link xlink:href="https://rocks.moonscript.org/modules/kikito/ansicolors">ansicolors</link> for color manipulation,
-<link xlink:href="https://rocks.moonscript.org/modules/luarocks/htmlparser">htmlparser</link> for changing HTML text into a tree of elements,
-<link xlink:href="https://rocks.moonscript.org/modules/kikito/i18n">i18n</link> an internationalization library,
-<link xlink:href="https://rocks.moonscript.org/modules/luarocks/lposix">lposix</link> a POSIX library,
-<link xlink:href="https://rocks.moonscript.org/modules/luarocks/lua-spore">lua-Spore</link> a generic ReST client,
-<link xlink:href="https://rocks.moonscript.org/modules/luarocks/tekui">TekUI</link> a GUI toolkit.
-For example, to bring in the i18n package: install luarocks, say <code>luarocks install i18n</code>,
-start Tarantool, and say <code>require('i18n')</code>.
-</para>
-
-<para>
-The rest of this chapter is an introduction and reference that has what's needed for programming and
-administration with the built-in packages.
-</para>
-
 
 <xi:include href="stored-procedures.xml" />
 <xi:include href="triggers.xml" />
diff --git a/doc/user/lua-tutorial.xml b/doc/user/lua-tutorial.xml
index 4eea0ce7d5..db4e85752e 100644
--- a/doc/user/lua-tutorial.xml
+++ b/doc/user/lua-tutorial.xml
@@ -441,7 +441,7 @@ main_function()!
 The screen now looks like this:
 
 <programlisting>
-tarantool&gt; <userinput>setopt delimiter = '!'!</userinput>
+tarantool&gt; <userinput>console = require('console'); console.delimiter('!')</userinput>
 tarantool&gt; <userinput>function string_function()</userinput>
         -&gt;   <userinput>local random_number</userinput>
         -&gt;   <userinput>local random_string</userinput>
diff --git a/doc/user/stored-procedures.xml b/doc/user/stored-procedures.xml
index 8c6362a3ae..cc9ac0f670 100644
--- a/doc/user/stored-procedures.xml
+++ b/doc/user/stored-procedures.xml
@@ -171,6 +171,137 @@ tarantool> <userinput>box.space[33]:drop()</userinput>
 ...
 </computeroutput></programlisting>
     </para>
+    
+<para>
+<bridgehead renderas="sect4">The "Batteries Included" Lua Software Distribution</bridgehead>
+Tarantool incorporates open-source
+precompiled packages which Tarantool's developers
+have tested for compatibility -- the "built-in" packages.
+Tarantool specializes in packages which aid
+database applications or which Tarantool's own developers
+use to make database-related tools.
+At the same time.
+Tarantool makes it easy to add new Lua packages
+from <link xlink:href=" http://luarocks.org/">LuaRocks</link> -- the "downloadable" packages.
+</para>
+
+<para>
+The included language processor is <link xlink:href="http://luajit.org/">LuaJIT</link>.
+Major "built-in" components are: fibers,
+<link xlink:href="http://msgpack.org">MsgPack</link>,
+digest, JSON, <link xlink:href="http://en.wikipedia.org/wiki/Yaml">YAML</link>,
+<link xlink:href="http://en.wikipedia.org/wiki/Inter-process_communication">IPC</link> , and box.
+</para>
+
+<para>
+LUAJIT is a processor for the entire Lua language. 
+This differs from the original Lua interpreter from
+<link xlink:href="http://www.puc-rio.br/index.html">Pontifícia Universidade Católica do Rio de Janeiro</link>
+("RIO-PUC" <link xlink:href="http://www.lua.org/">Lua</link>) 
+because the JIT stands for "Just In Time" compiling, that
+is, it can compile some Lua code into machine executable form the
+after a few executions of the code.
+The result is that some
+loops will run as quickly as an equivalent C program.
+Also some precompiled C code can be brought in using
+LuaJIT's FFI (<link xlink:href="https://en.wikipedia.org/wiki/Foreign_function_interface">Foreign Function Interface</link>).
+Examples for using FFI exist on the Internet, for example 
+<link xlink:href="https://github.com/tarantool/tarantool/blob/master/src/box/lua/tuple.lua">tuple.lua</link> on the tarantool.org site.
+</para>
+
+<para>
+LuaJIT has been compared to competitive implementations
+and found to be reliable and efficient,
+provided one takes advantage of it where <link xlink:href="http://wiki.luajit.org/Numerical-Computing-Performance-Guide">performance</link> counts. 
+</para>
+
+    <para>
+        Apart from increased performance, LuaJIT provides such
+        features as <link
+        xlink:href="http://bitop.luajit.org/">bitwise
+        operations</link> and <link xlink:href="#tonumber64">64-bit integer arithmetic.</link>
+    </para>
+
+<para>
+FIBERS are like Lua coroutines, but as <link xlink:href="http://members.chello.nl/~w.couwenberg/fibers.htm">one fiber developer</link>
+put it: "The main difference between a coroutine and a fiber
+is that a running fiber can be suspended anywhere in a call
+chain, regardless of its C and Lua call stack nesting levels."       
+</para>
+
+<para>
+MSGPACK is a relatively new way to serialize data.                    
+The point of MsgPack is that it can
+handle Lua types and C types, with structures and nesting,
+without the overhead of an SGML-style markup language.
+</para>
+
+<para>
+DIGEST is a cryptography package for CRC32, SHA, and MDA.
+Nothing new here -- except that Tarantool has made them into a
+package, so that one doesn't have to get each one of these
+things individually from the <link xlink:href="http://lua-users.org/wiki/CryptographyStuff">many that are available</link>.
+And, since Tarantool is binding with FFI rather than a traditional Lua C
+API, the routines should run faster on LuaJIT.
+</para>
+
+<para>
+JSON is a serialization format which has
+become popular in the web world. The package within
+Tarantool is derived from <link xlink:href="http://www.kyne.com.au/~mark/software/lua-cjson-manual.html">CJSON</link>
+which, according to <link xlink:href="http://lua-users.org/wiki/JsonModules">a survey</link>, 
+handles Unicode surrogate pairs and is robust when
+edge cases come up.
+</para>
+
+<para>
+YAML is short for "YAML Ain't a Markup Language". YAML is a            
+way to show data in human-readable form, without losing
+underlying information about typing, arrays, and structures.
+</para>
+
+<para>
+IPC is Inter-Process Communication.
+this is useful for implementations of task queues and long polling.
+</para>
+
+<para>
+BOX is the NoSQL DBMS that was developed by Tarantool
+and its community. Box's architecture and routines will be the
+subject of the next chapter.
+</para>
+
+<para>
+<bridgehead renderas="sect4">The Downloadable Packages</bridgehead>
+A directory of Lua Addons packages can be found on the <link xlink:href="http://lua-users.org/wiki/LuaAddons">Lua-users</link> wiki. 
+For a "managed package" system equivalent to Perl's CPAN and Ruby's RubyGems and Python's
+Eggs, one gets "rocks" (modules or packages) from <emphasis>LuaRocks</emphasis>.
+Either way, the installation requirement can be as simple as saying
+require('package-name')
+and the effect is a simple Lua table containing 
+functions and members, superficially like C/Java classes.
+</para>
+
+<para>
+There are <link xlink:href="https://rocks.moonscript.org/modules">several hundred LuaRocks packages</link> that are not built-in       
+but are reasonably easy to obtain by anyone with an Internet
+connection. Just as a sampling: ...
+<link xlink:href="https://rocks.moonscript.org/modules/kikito/ansicolors">ansicolors</link> for color manipulation,
+<link xlink:href="https://rocks.moonscript.org/modules/luarocks/htmlparser">htmlparser</link> for changing HTML text into a tree of elements,
+<link xlink:href="https://rocks.moonscript.org/modules/kikito/i18n">i18n</link> an internationalization library,
+<link xlink:href="https://rocks.moonscript.org/modules/luarocks/lposix">lposix</link> a POSIX library,
+<link xlink:href="https://rocks.moonscript.org/modules/luarocks/lua-spore">lua-Spore</link> a generic ReST client,
+<link xlink:href="https://rocks.moonscript.org/modules/luarocks/tekui">TekUI</link> a GUI toolkit.
+For example, to bring in the i18n package: install luarocks, say <code>luarocks install i18n</code>,
+start Tarantool, and say <code>require('i18n')</code>.
+</para>
+
+<para>
+The rest of this chapter is a reference that has what's needed for programming and
+administration with the built-in packages.
+</para>
+
+
 
 <variablelist>
 <title>Lua functions <code>tonumber64</code> and <code>dostring</code></title>
-- 
GitLab