On 19/11/2014 9:58 PM, Kirk Wolf wrote:
This is not a comment about the LUA4Z port, but at first glance I find the
module system a little confusing.

It's quite simple once you grok it http://www.lua.org/manual/5.1/manual.html#5.3. It's very flexible. You can add your own module system quite easily if you so desire.

For example:   I was trying to find the lua code that implements the "io"
module, and how that links into stdio - IOW how does "io.open()" get to the
C library fopen() ?

The Lua core and standard library are C modules linked into liblua.so. Lua loads the standard library modules at initialization http://www.lua.org/source/5.1/linit.c.html. luaopen_io creates the io module table which contains the open function http://www.lua.org/source/5.1/liolib.c.html#iolib. The function linkage between C and Lua is fast. The VM simply loads a function pointer from a hash table and calls it. All parameters and return values are placed onto a stack. It took me a while to get my head around the stack but it's one of the reasons Lua is so fast. There are no reference counted objects or references in play at all.

Kirk Wolf
Dovetailed Technologies
http://dovetail.com

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to