Mercurial Hosting > luan
diff website/src/diff.html.luan @ 389:497d4ef0a89f
documentation work
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Fri, 24 Apr 2015 12:25:50 -0600 |
parents | 23d075ce1e48 |
children | bfbbce690bba |
line wrap: on
line diff
--- a/website/src/diff.html.luan Thu Apr 23 18:54:35 2015 -0600 +++ b/website/src/diff.html.luan Fri Apr 24 12:25:50 2015 -0600 @@ -131,19 +131,19 @@ <p>Luan has no numeric <b>for</b> statement. Luan only has generic <b>for</b> statement. Instead of the numeric <b>for</b> statement, Luan uses the <tt>range</tt> function in a generic <b>for</b> statement like this:</p> -<tt><pre> +<p><tt><pre> for i in range(from,to,step) do <i>block</i> end - </pre></tt> +</pre></tt></p> - <p>The Luan generic <b>for</b> statement is simpler than the Lua version because Luan only uses and expression, not an explist. So a <b>for</b> statement like:</p> +<p>The Luan generic <b>for</b> statement is simpler than the Lua version because Luan only uses and expression, not an explist. So a <b>for</b> statement like:</p> - <tt><pre> +<p><tt><pre> for var_1, ยทยทยท, var_n in exp do block end - </pre></tt> +</pre></tt></p> - <p>is equivalent to the code:</p> +<p>is equivalent to the code:</p> - <tt><pre> +<p><tt><pre> do local f = exp while true do @@ -152,37 +152,37 @@ block end end -</pre></tt> +</pre></tt></p> <h4 margin-top="1em"><a name="logical">Logical Statements</a></h4> <p>Unlike Lua, Luan allows <b>or</b> and <b>and</b> expressions to be stand-alone statements. This is useful in cases like this:</p> -<tt><pre> +<p><tt><pre> x==5 or error "x should be 5" -</pre></tt> +</pre></tt></p> <h4 margin-top="1em"><a name="template-stmt">Template Statements</a></h4> <p>Template statements are based on <a href="#template-expr">template exressions</a> and provide the full equivalent of <a href="http://en.wikipedia.org/wiki/JavaServer_Pages">JSP</a> but in a general way. Template statements write the equivalent template exression to standard output. For example:</p> -<tt><pre><%=Html.encode[[ +<p><tt><pre><%=Html.encode[[ local name = "Bob" %> Hello <%=name%>! Bye <%=name%>. <% -]]%></pre></tt> +]]%></pre></tt></p> <p>is equivalent to the code:</p> -<tt><pre><%=Html.encode[[ +<p><tt><pre><%=Html.encode[[ local name = "Bob" require("luan:Io").stdout.write( %> Hello <%=name%>! Bye <%=name%>. <% ) -]]%></pre></tt> +]]%></pre></tt></p> <h3 margin-top="1em"><a name="expr">Expressions</a></h3> @@ -202,17 +202,17 @@ <p>Luan adds a new type of expression based on <a href="http://en.wikipedia.org/wiki/JavaServer_Pages">JSP</a> called template expressions. Template expressions return multiple values. Here is an example:</p> -<tt><pre><%=Html.encode[[ +<p><tt><pre><%=Html.encode[[ local name = "Bob" write( %>Hello <%=name%>!<% ) -]]%></pre></tt> +]]%></pre></tt></p> <p>This is equivalent to the code:</p> -<tt><pre> +<p><tt><pre> local name = "Bob" write( "Hello ", name, "!" ) -</pre></tt> +</pre></tt></p> <p>The strings in template expressions may be multiple lines.</p>