[Date Prev][Date Next][Thread Prev][Thread Next]
- From: Dirk Laurie <dpl@...>
- Date: Fri, 9 Sep 2011 21:58:26 +0200
On Thu, Sep 08, 2011 at 08:33:51AM +0200, Dimiter "malkia" Stanev wrote:
> > This might be a controversial statement, but I recently also reflected
> > 1990ies C - Pascal relationship. The Pascal/Lua actually the more
> > sane, the nicer looking, better developed language with faster parser,
> > power and big industries behind it.
> I miss Pascal too. My coding language up to 2000. Started C 1993.
I still use Pascal. Not GNU Pascal, but Free Pascal. It even has
a lua unit with bindings for the Lua API.
All routines from the C API and auxiliary library mentioned in
the Lua 5.1 reference manual are supported in the lua, lualib
or lauxlib libraries of Free Pascal 2.4. There is no documentation,
but you can use the Lua manual since the call sequences are basically
identical, except for the following:
luaL_Reg => lua_CFunction
Most others are obvious, with P used for pointer, e.g.
luaState* => Plua_State
or standard, e.g.
void* => Pointer
int => Integer
You can always look at the interface of lauxlib.pas etc
(package fpc-source on Ubuntu) to make sure.
Some routine names have no L (probably typos):
luaL_dofile => lua_dofile
luaL_dostring => lua_dostring
luaL_getmetatable => lua_Lgetmetatable
It's annoying that Free Pascal has long strings, but no way of
continuing a string constant across line boundaries.
Minimal usage example:
uses lua, lualib, lauxlib;
var L: Plua_State;
L := lua_open(); luaL_openlibs(L);
'for k in string.gmatch("a,b,c,d,e,f,g,h","([^,]+),") do print(k) end'
Simply fpc that and run the executable.