comparison website/src/diff.html.luan @ 1812:f44dcb3fedf7

docs - add code block
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 10 Jun 2024 14:41:48 -0600
parents ba43135bb98d
children fa0e73119b7c
comparison
equal deleted inserted replaced
1811:55d89a183c82 1812:f44dcb3fedf7
136 title = "For Statement" 136 title = "For Statement"
137 content = function() 137 content = function()
138 %> 138 %>
139 <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 <code>range</code> function in a generic <b>for</b> statement like this:</p> 139 <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 <code>range</code> function in a generic <b>for</b> statement like this:</p>
140 140
141 <pre> 141 <code block>
142 for i in range(from,to,step) do <em>block</em> end 142 for i in range(from,to,step) do <em>block</em> end
143 </pre> 143 </code>
144 144
145 <p>The Luan generic <b>for</b> statement is simpler than the Lua version because Luan only uses an expression, not an explist. So a <b>for</b> statement like:</p> 145 <p>The Luan generic <b>for</b> statement is simpler than the Lua version because Luan only uses an expression, not an explist. So a <b>for</b> statement like:</p>
146 146
147 <pre> 147 <code block>
148 for var_1, &middot;&middot;&middot;, var_n in exp do block end 148 for var_1, &middot;&middot;&middot;, var_n in exp do block end
149 </pre> 149 </code>
150 150
151 <p>is equivalent to the code:</p> 151 <p>is equivalent to the code:</p>
152 152
153 <pre> 153 <code block>
154 do 154 do
155 local f = exp 155 local f = exp
156 while true do 156 while true do
157 local var_1, &middot;&middot;&middot;, var_n = f() 157 local var_1, &middot;&middot;&middot;, var_n = f()
158 if var_1 == nil then break end 158 if var_1 == nil then break end
159 block 159 block
160 end
161 end 160 end
162 </pre> 161 end
162 </code>
163 <% 163 <%
164 end 164 end
165 } 165 }
166 ["try"] = { 166 ["try"] = {
167 title = "Try Statement" 167 title = "Try Statement"
175 title = "Logical Statements" 175 title = "Logical Statements"
176 content = function() 176 content = function()
177 %> 177 %>
178 <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> 178 <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>
179 179
180 <pre> 180 <code block>
181 x==5 or error "x should be 5" 181 x==5 or error "x should be 5"
182 </pre> 182 </code>
183 <% 183 <%
184 end 184 end
185 } 185 }
186 template_stmt = { 186 template_stmt = {
187 title = "Template Statements" 187 title = "Template Statements"