[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Lua in the NetBSD kernel
- From: Marc Balmer <marc@...>
- Date: Tue, 16 Aug 2011 13:31:34 +0200
I just got it working. Here is a a transcript of a session. The
commandline prompt is 'amd64 #', console output is prefixed with console:
First, lets load the lua(4) module...
amd64# modload lua
console: lua0: Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio
Now create a Lua state...
amd64# luactl create s1
console: lua0: state s1 created
Now try to execute the Lua code 'print("Hello, kernel world")' from file
./test.lua in state s1...
amd64# luactl load s1 ./test.lua
console: lua0: loading ./test.lua into state s1
console: lua0: error executing Lua code
console: lua0: [string "test.lua"]:1: attempt to call global 'print' (a
nil value)
Of course! Newly created states are empty, they have no functions. So
lets provide state s1 with the print function, it is in a Lua module I
called luaempty. First load the module, then let s1 use it...
amd64# modload luaempty
console: registered lua module luaempty
amd64# luactl require s1 luaempty
console: lua0: requiring module luaempty to state s1
Now we retry loading (and executing) ./test.lua...
amd64# luactl load s1 ./test.lua
console: Hello, kernel world