Mercurial Hosting > luan
changeset 465:47c7de1f2322
documentation work
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 07 May 2015 22:10:45 -0600 |
parents | eddf7c73373b |
children | 55a86fc4701b |
files | website/src/diff.html.luan website/src/manual.html.luan |
diffstat | 2 files changed, 69 insertions(+), 50 deletions(-) [+] |
line wrap: on
line diff
--- a/website/src/diff.html.luan Thu May 07 21:31:19 2015 -0600 +++ b/website/src/diff.html.luan Thu May 07 22:10:45 2015 -0600 @@ -48,16 +48,18 @@ <li><a href="#control">Control Structures</a></li> <li><a href="#for">For Statement</a></li> <li><a href="#logical">Logical Statements</a></li> - <li><a href="#template-stmt">Template Statements</a></li> + <li><a href="#template_stmt">Template Statements</a></li> </ul> </li> <li> <a href="#expr">Expressions</a> <ul> + <li><a href="#conversions">Coercions and Conversions</a></li> <li><a href="#bit">Bitwise Operators</a></li> - <li><a href="#local-ops">Logical Operators</a></li> - <li><a href="#fn-call">Function Calls</a></li> - <li><a href="#template-expr">Template Expressions</a></li> + <li><a href="#logical_ops">Logical Operators</a></li> + <li><a href="#concatenation">Concatenation</a></li> + <li><a href="#fn_calls">Function Calls</a></li> + <li><a href="#template_expr">Template Expressions</a></li> </ul> </li> </ul> @@ -99,7 +101,7 @@ <h3 margin-top="1em"><a name="meta">Metatables and Metamethods</a></h3> -<p>to document later...</p> +<p>Luan only has metatable for tables, not for other types.</p> <h3 margin-top="1em"><a name="gc">Garbage Collection</a></h3> @@ -164,59 +166,36 @@ x==5 or error "x should be 5" </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> +<h4 margin-top="1em"><a name="template_stmt">Template Statements</a></h4> -<p><tt><pre><%=Html.encode[[ - local name = "Bob" - %> - Hello <%=name%>! - Bye <%=name%>. - <% -]]%></pre></tt></p> +<p>Template statements are a Luan addition that don't exist in Lua. See <a href="manual.html#template_stmt">Template Statements</a> in the Luan Reference Manual.</p> -<p>is equivalent to the code:</p> - -<p><tt><pre><%=Html.encode[[ - local name = "Bob" - require("luan:Io").stdout.write( %> - Hello <%=name%>! - Bye <%=name%>. - <% ) -]]%></pre></tt></p> <h3 margin-top="1em"><a name="expr">Expressions</a></h3> +<h4 margin-top="1em"><a name="conversions">Coercions and Conversions</a></h4> + +<p>Unlike Lua, Luan does not do automatic conversions of strings to numbers.</p> + <h4 margin-top="1em"><a name="bit">Bitwise Operators</a></h4> -<p>Bitwise operators appear to be new addition to Lua 5.3 and didn't exist in Lua 5.2. Luan does not support bitwise operators, but these can be added if there is a need.</p> +<p>Bitwise operators appear to be a new addition to Lua 5.3 and didn't exist in Lua 5.2. Luan does not support bitwise operators, but these can be added if there is a need.</p> -<h4 margin-top="1em"><a name="local-ops">Logical Operators</a></h4> +<h4 margin-top="1em"><a name="logical_ops">Logical Operators</a></h4> <p>The only change in Luan is that <b>not</b> must take a boolean argument. This helps catch errors and makes code more readable.</p> -<h4 margin-top="1em"><a name="fn-call">Function Calls</a></h4> +<h4 margin-top="1em"><a name="concatenation">Concatenation</a></h4> + +<p>Unlike Lua, Luan converts all concatenation operands to strings. + +<h4 margin-top="1em"><a name="fn_calls">Function Calls</a></h4> <p>Luan does not support Lua's <tt>v:name(args)</tt> style object-oriented function call. Object oriented programming is done in Luan using closures, so this feature is not needed.</p> -<h4 margin-top="1em"><a name="template-expr">Template Expressions</a></h4> - -<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> - -<p><tt><pre><%=Html.encode[[ - local name = "Bob" - write( %>Hello <%=name%>!<% ) -]]%></pre></tt></p> +<h4 margin-top="1em"><a name="template_expr">Template Expressions</a></h4> -<p>This is equivalent to the code:</p> - -<p><tt><pre> - local name = "Bob" - write( "Hello ", name, "!" ) -</pre></tt></p> - -<p>The strings in template expressions may be multiple lines.</p> +<p>Template expressions are a Luan addition that don't exist in Lua. See <a href="manual.html#template_expr">Template Expressions</a> in the Luan Reference Manual.</p> </div>
--- a/website/src/manual.html.luan Thu May 07 21:31:19 2015 -0600 +++ b/website/src/manual.html.luan Thu May 07 22:10:45 2015 -0600 @@ -60,6 +60,7 @@ <li><a href="#for">For Statement</a></li> <li><a href="#fn_stmt">Function Calls as Statements</a></li> <li><a href="#local_stmt">Local Declarations</a></li> + <li><a href="#template_stmt">Template Statements</a></li> </ul> </li> <li> @@ -75,6 +76,7 @@ <li><a href="#constructors">Table Constructors</a></li> <li><a href="#fn_calls">Function Calls</a></li> <li><a href="#fn_def">Function Definitions</a></li> + <li><a href="#template_expr">Template Expressions</a></li> </ul> </li> <li><a href="#visibility">Visibility Rules</a></li> @@ -1107,6 +1109,28 @@ The visibility rules for local variables are explained in <a href="#visibility">Visibility Rules</a>. +<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> + +<p><tt><pre><%=Html.encode[[ + local name = "Bob" + %> + Hello <%=name%>! + Bye <%=name%>. + <% +]]%></pre></tt></p> + +<p>is equivalent to the code:</p> + +<p><tt><pre><%=Html.encode[[ + local name = "Bob" + require("luan:Io").stdout.write( %> + Hello <%=name%>! + Bye <%=name%>. + <% ) +]]%></pre></tt></p> + <h3 margin-top="1em"><a name="expressions">Expressions</a></h3> @@ -1223,13 +1247,11 @@ <h4 margin-top="1em"><a name="conversions">Coercions and Conversions</a></h4> <p> -Luan provides some automatic conversions between some -types and representations at run time. -String concatenation converts all of its arguments to strings. - -Luan also converts strings to numbers -whenever a number is expected. - +Luan generally avoids automatic conversions. +String concatenation automatically converts all of its arguments to strings. + +<p> +Luan provides library functions for explicit type conversions. @@ -1696,6 +1718,24 @@ then the function returns with no results. +<h4 margin-top="1em"><a name="template_expr">Template Expressions</a></h4> + +<p>Luan template expression are based on <a href="http://en.wikipedia.org/wiki/JavaServer_Pages">JSP</a>. Template expressions return multiple values. Here is an example:</p> + +<p><tt><pre><%=Html.encode[[ + local name = "Bob" + write( %>Hello <%=name%>!<% ) +]]%></pre></tt></p> + +<p>This is equivalent to the code:</p> + +<p><tt><pre> + local name = "Bob" + write( "Hello ", name, "!" ) +</pre></tt></p> + +<p>The strings in template expressions may be multiple lines.</p> + <h3 margin-top="1em"><a name="visibility">Visibility Rules</a></h3>