Lua

From MiniScript Wiki
Revision as of 21:01, 10 December 2022 by JoeStrout (talk | contribs)
Jump to navigation Jump to search

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.

Data Types

Differences