[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: [ANN] A tool to learn / teach Lua's C API
- From: Tyler Neylon <tylerneylon@...>
- Date: Tue, 1 Dec 2015 02:44:18 -0800
The apidemo module mimics Lua's C API within Lua itself.
It's meant to help folks learn the API by using it interactively from
the interpreter. They can see directly how each call affects the
stack.
For example:
> apidemo = require 'apidemo'
> apidemo.setup_globals()
> L = luaL_newstate(); -- Using semicolons to be more C-like.
> lua_getglobal(L, "print");
stack: function:print
> lua_pushstring(L, "hi!");
stack: function:print 'hi!'
> lua_call(L, 1, 0);
hi!
stack: <empty>
This is available via luarocks. The source and more info can be found here:
https://github.com/tylerneylon/lua_api_demo
thanks!
- Tyler