Difference between revisions of "Lua"
(Created page with "Lua is a scripting language first released in 1993, and particularly popular as an embedded language. This article compares Lua to MiniScript, and may be useful to people com...") |
|||
Line 1: | Line 1: | ||
Lua is a scripting language first released in 1993, and particularly popular as an embedded language. This article compares Lua to MiniScript, and may be useful to people coming to MiniScript with a background in Lua. | Lua is a scripting language first released in 1993, and particularly popular as an embedded language. This article compares Lua to MiniScript, and may be useful to people coming to MiniScript with a background in Lua. | ||
− | For a side-by-side comparison on a | + | For a side-by-side comparison on a collection of short programs, see [https://miniscript.org/compare/lua.html here]. |
== Similarities == | == Similarities == | ||
+ | |||
+ | === Block Syntax === | ||
+ | |||
+ | Both Lua and MiniScript delineate code blocks and control structures with explicit keywords. There are some minor differences in syntax, summarized in the table below. | ||
+ | |||
+ | {| class="wikitable" | ||
+ | |- | ||
+ | ! Lua | ||
+ | ! MiniScript | ||
+ | |- | ||
+ | | function / end | ||
+ | | function / end function | ||
+ | |- | ||
+ | | if / elseif / end | ||
+ | | if / else if / end if | ||
+ | |- | ||
+ | | while ... do / end | ||
+ | | while / end while | ||
+ | |- | ||
+ | | for i = 1, 10, 2 do / end<br /> | ||
+ | | for i in range(1, 10, 2) / end for<br /> | ||
+ | |- | ||
+ | | repeat / until | ||
+ | | style="font-style:italic;" | (no direct equivalent) | ||
+ | |} | ||
+ | |||
+ | The most notable difference is that while Lua uses <c>end</c> alone to terminate a <c>function</c>, <c>if</c>, <c>while</c>, or <c>for</c> block, MiniScript uses <c>end function</c>, <c>end if</c>, <c>end while</c>, and <c>end for</c> respectively. MiniScript lacks a <c>repeat</c>-<c>until</c> structure; the standard idiom is to use a <c>while true</c> (infinite) loop, and [[break]] out of it when termination conditions are met. | ||
=== Data Types === | === Data Types === | ||
+ | |||
+ | |||
+ | == Differences == |
Revision as of 21:01, 10 December 2022
Lua is a scripting language first released in 1993, and particularly popular as an embedded language. This article compares Lua to MiniScript, and may be useful to people coming to MiniScript with a background in Lua.
For a side-by-side comparison on a collection of short programs, see here.
Similarities
Block Syntax
Both Lua and MiniScript delineate code blocks and control structures with explicit keywords. There are some minor differences in syntax, summarized in the table below.
Lua | MiniScript |
---|---|
function / end | function / end function |
if / elseif / end | if / else if / end if |
while ... do / end | while / end while |
for i = 1, 10, 2 do / end |
for i in range(1, 10, 2) / end for |
repeat / until | (no direct equivalent) |
The most notable difference is that while Lua uses end
alone to terminate a function
, if
, while
, or for
block, MiniScript uses end function
, end if
, end while
, and end for
respectively. MiniScript lacks a repeat
-until
structure; the standard idiom is to use a while true
(infinite) loop, and break out of it when termination conditions are met.