RiscLua is a dialect of Lua for use in RISC OS. It differs from Lua in a few minor details of syntax. Anybody wanting to try their hand with RiscLua should dip into Programming in Lua, by Roberto Ierusalimschy (Fourth edition: ISBN 978-85-903798-6-7).
I expect most readers have some acquaintance with BBC BASIC, and perhaps a few with C. These notes draw attention to aspects of Lua which may seem strange initially. A superficial glance at some Lua code will reveal many similarities, particularly in constructs such as
while ... do ... end repeat ... until ... if ... then ... else ... end for ... do ... endand even (dare I mention it?)
goto ...which may serve to hide more fundamental differences and concepts such as lexical scoping and anonymous functions.
Whereas in BASIC variables tend to be global variables, and the notion of local variable was historically something of an afterthought, in Lua, despite appearances, there are no global variables. There are only variables local to a block or values in tables. What appear as global variables are values of the table _G. The whole program constitutes a single block, so what is the difference between using a variable local to the global block, and using a global variable? In practice very little. Local variables are faster to look up, and it is good practice to use them whenever possible.
BASIC encourages a top down approach to programming, because FN and PROC definitions come after the main body of the program. By contrast, in Lua, a value that is not built-in cannot be used until after it has been defined. This means that programs tend to be written, and read, backwards. The main part of the program comes last, and the definitions are filled in before. This is no big deal once you are used to it.