Risc Os Lua |
|
RiscLua uses 32-bit integers for its number type, though arbitrary precision numbers can be used via the bc
library. Bit-twiddling operators are provided as extensions to the VM. The riscos
library provides a directory iterator and filetype function, and mimics BBC Basic's access to the operating system in providing functions dim
and sys
and operators !
,?
and $
. These operators are implemented as tables, with metamethods so that, for example ?
appears to be a table of byte-values indexed by addresses. The dim
function creates a userdatum pointing to a block of allocated memory. It returns the address of the block. As a side-effect it assigns the userdatum as the value of the built-in table riscos.block
indexed by its address. So (in the environment of riscos
) the statement
local x = dim (array_size)
creates an array at the address x, which can be rendered garbage-collectible by the statement
block[x] = nil
The expression #block[x]
returns array_size if the array is live and nil otherwise.
RiscLua uses Peter Shook's patch to provide statements
local <varlist> in <table_expr>
and offers the syntactic sugar \
(for function
) and =>
(for return
). Compound assignment statements can be used (but not for multi-assignments).
Sadly RISC OS has as yet no dynamic linking facility, so loadlib
cannot be used.
The StrongED editor has a Lua mode for syntax colouring and provides a development environment: a Lua script in one window can act on the text in another and put its output into yet another (or replace it).