comparison website/src/manual.html.luan @ 465:47c7de1f2322

documentation work
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 07 May 2015 22:10:45 -0600
parents eddf7c73373b
children 9b51e2413cab
comparison
equal deleted inserted replaced
464:eddf7c73373b 465:47c7de1f2322
58 <li><a href="#assignment">Assignment</a></li> 58 <li><a href="#assignment">Assignment</a></li>
59 <li><a href="#control">Control Structures</a></li> 59 <li><a href="#control">Control Structures</a></li>
60 <li><a href="#for">For Statement</a></li> 60 <li><a href="#for">For Statement</a></li>
61 <li><a href="#fn_stmt">Function Calls as Statements</a></li> 61 <li><a href="#fn_stmt">Function Calls as Statements</a></li>
62 <li><a href="#local_stmt">Local Declarations</a></li> 62 <li><a href="#local_stmt">Local Declarations</a></li>
63 <li><a href="#template_stmt">Template Statements</a></li>
63 </ul> 64 </ul>
64 </li> 65 </li>
65 <li> 66 <li>
66 <a href="#expressions">Expressions</a> 67 <a href="#expressions">Expressions</a>
67 <ul> 68 <ul>
73 <li><a href="#length">The Length Operator</a></li> 74 <li><a href="#length">The Length Operator</a></li>
74 <li><a href="#precedence">Precedence</a></li> 75 <li><a href="#precedence">Precedence</a></li>
75 <li><a href="#constructors">Table Constructors</a></li> 76 <li><a href="#constructors">Table Constructors</a></li>
76 <li><a href="#fn_calls">Function Calls</a></li> 77 <li><a href="#fn_calls">Function Calls</a></li>
77 <li><a href="#fn_def">Function Definitions</a></li> 78 <li><a href="#fn_def">Function Definitions</a></li>
79 <li><a href="#template_expr">Template Expressions</a></li>
78 </ul> 80 </ul>
79 </li> 81 </li>
80 <li><a href="#visibility">Visibility Rules</a></li> 82 <li><a href="#visibility">Visibility Rules</a></li>
81 </ul> 83 </ul>
82 </div> 84 </div>
1105 1107
1106 <p> 1108 <p>
1107 The visibility rules for local variables are explained in <a href="#visibility">Visibility Rules</a>. 1109 The visibility rules for local variables are explained in <a href="#visibility">Visibility Rules</a>.
1108 1110
1109 1111
1112 <h4 margin-top="1em"><a name="template_stmt">Template Statements</a></h4>
1113
1114 <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>
1115
1116 <p><tt><pre><%=Html.encode[[
1117 local name = "Bob"
1118 %>
1119 Hello <%=name%>!
1120 Bye <%=name%>.
1121 <%
1122 ]]%></pre></tt></p>
1123
1124 <p>is equivalent to the code:</p>
1125
1126 <p><tt><pre><%=Html.encode[[
1127 local name = "Bob"
1128 require("luan:Io").stdout.write( %>
1129 Hello <%=name%>!
1130 Bye <%=name%>.
1131 <% )
1132 ]]%></pre></tt></p>
1133
1110 1134
1111 1135
1112 <h3 margin-top="1em"><a name="expressions">Expressions</a></h3> 1136 <h3 margin-top="1em"><a name="expressions">Expressions</a></h3>
1113 1137
1114 <p> 1138 <p>
1221 1245
1222 1246
1223 <h4 margin-top="1em"><a name="conversions">Coercions and Conversions</a></h4> 1247 <h4 margin-top="1em"><a name="conversions">Coercions and Conversions</a></h4>
1224 1248
1225 <p> 1249 <p>
1226 Luan provides some automatic conversions between some 1250 Luan generally avoids automatic conversions.
1227 types and representations at run time. 1251 String concatenation automatically converts all of its arguments to strings.
1228 String concatenation converts all of its arguments to strings. 1252
1229 1253 <p>
1230 Luan also converts strings to numbers 1254 Luan provides library functions for explicit type conversions.
1231 whenever a number is expected.
1232
1233 1255
1234 1256
1235 1257
1236 1258
1237 <h4 margin-top="1em"><a name="relational">Relational Operators</a></h4> 1259 <h4 margin-top="1em"><a name="relational">Relational Operators</a></h4>
1693 Results are returned using the <b>return</b> statement (see <a href="#control">Control Structures</a>). 1715 Results are returned using the <b>return</b> statement (see <a href="#control">Control Structures</a>).
1694 If control reaches the end of a function 1716 If control reaches the end of a function
1695 without encountering a <b>return</b> statement, 1717 without encountering a <b>return</b> statement,
1696 then the function returns with no results. 1718 then the function returns with no results.
1697 1719
1720
1721 <h4 margin-top="1em"><a name="template_expr">Template Expressions</a></h4>
1722
1723 <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>
1724
1725 <p><tt><pre><%=Html.encode[[
1726 local name = "Bob"
1727 write( %>Hello <%=name%>!<% )
1728 ]]%></pre></tt></p>
1729
1730 <p>This is equivalent to the code:</p>
1731
1732 <p><tt><pre>
1733 local name = "Bob"
1734 write( "Hello ", name, "!" )
1735 </pre></tt></p>
1736
1737 <p>The strings in template expressions may be multiple lines.</p>
1698 1738
1699 1739
1700 1740
1701 <h3 margin-top="1em"><a name="visibility">Visibility Rules</a></h3> 1741 <h3 margin-top="1em"><a name="visibility">Visibility Rules</a></h3>
1702 1742