Lua (version 3.2) was first ported to RISC OS by Reuben Thomas,
who has since, alas, left the RISC OS scene. Soon afterwards Lua
version 4.0 came out, at which point I started experimenting with
the Lua sources to see if I could add to them facilities for calling
RISC OS SWIs. In that way RiscLua started life. Its initial development
was rather haphazard.
I was faced with two problems. First, the standard Lua sources use
64-bit floating point numbers (doubles
) by default.
Unfortunately the ARM chips mostly used by RISC OS did not then have on-chip
floating point operations.
The Lua sources have since been improved to make it easier to use alternative
number types. My earliest efforts used the default doubles; later I
used 32-bit integers as the default for RiscLua, reckoning that the
sacrifice of not having floating point numbers was worth the efficiency
gained on ARM chips. Later versions of RiscLua gave back the use
of floating point numbers; first of all, version 3.10 used the MAPM
bignumber package. This was abandoned as clumsy in version 3.20.
In version 4.00 the doubles
library was introduced,
which implements 64-bit floating point numbers, not in the Lua virtual
machine (which keeps to 32-bit integers) but as objects in the heap.
Second, RISC OS SWIs use registers as pointers to arrays of data,
whereas Lua, for reasons of portability and security, avoids such
things. However, its notion of userdata
provided enough to implement what was required. It was not until
version 3.00 of RiscLua, with the introduction of the block
libraries, that the RISC OS
calling interface was properly rationalized. In version 3.30 bitwise
operations on integers were implemented more efficiently using extra
opcodes for the Lua virtual machine. Programs not using them should still
compile to virtual machine code that is runnable on other platforms.
Version 5.00 reverts to an earlier, simpler approach. It replaces the block
libraries by the single library riscos
and also moves into it the directory iterator and
filetype functions formerly in os
. The syntax is now
much closer to that of Basic. Adopting Basic's confusion of addresses
and pointers with integers is somewhat against the spirit of Lua,
though the consequent insecurity will not affect pure Lua programs,
only those whose use of SWIs requires the presence of buffers for
passing data between program and operating system.
Version 5.30 is based on Lua 5.2(beta). It should run programs written
for RiscLua 5.00; compiled programs will need to be recompiled.
Version 5.40 is based on Lua 5.2. It is backwards compatible with
5.30 but makes dim
ed blocks garbage-collectible.
After a statement x = riscos.dim(n)
, a userdatum riscos.block[x]
is created. Applying # to it yields the
number of bytes in the block - useful for checking overflow. Setting it
to nil renders the block garbage-collectible. Version 5.41 is based on
Lua 5.2.1 and is backwards compatible with 5.40. Version 5.50 replaces
the doubles library by the arbitrary-precision bc library. Version 5.60
is based on the final version of Lua 5.2.2 and version 0.12 of the Lpeg
library. Version 5.70 adds the alternative syntax x op = y
for x = x op y
for the operations .. + - * /
^ % & | ^^ << >>
. Version 5.71 uses LUA_INIT to add
error throwback with a function riscos.throw
DDEUtils module is available. Format strings can be used as if they
Version 6 is made possible by the release of GCC 4.7.2 which
affords floating point hardware (for ARMv7) and
dynamically loadable libraries. Thus RiscLua can now revert to much
greater conformance with the standard Lua distribution. Numbers
need no longer be restricted to 32-bit integers. The riscos
libraries are now loadable dynamically and are not built in.
The only difference for users is that old programs must be
modified by the insertion of appropriate require