chickadee » lua

Outdated egg!

This is an egg for CHICKEN 4, the unsupported old release. You're almost certainly looking for the CHICKEN 5 version of this egg, if it exists.

If it does not exist, there may be equivalent functionality provided by another egg; have a look at the egg index. Otherwise, please consider porting this egg to the current version of CHICKEN.

Lua

Introduction

This extension embeds the Lua interpreter into a CHICKEN extension.

Source code for the Lua VM is included (version 5.1).

Requires

dollar

API

lua-open

lua-openprocedure

Creates and returns a fresh Lua execution context containing all base libraries.

lua-close

lua-close STATEprocedure

Closes a Lua execution context and performs all necessary cleanup. The effect of using Lua data from the closed context is undefined.

lua-run-string

lua-run-string STATE STRING #!optional NAMEprocedure

Executes the Lua statements in STRING and returns its result(s). The optional argument NAME can be given to identify the source of the Lua code (used in error messages).

lua-run-file

lua-run-file STATE PATHNAMEprocedure

Executes the statements in the file designated by PATHNAME and returns any result(s).

lua-eval

lua-eval STATE STRINGprocedure

Evaluates the Lua expression in STRING and returns any result(s).

lua-call

lua-call LUAFUNCTION ARG ...procedure

Calls the Lua function LUAFUNCTION which must have been obtained through evaluation of Lua code with the given arguments.

lua-function?

lua-function? Xprocedure

Returns #t if X is a Lua function or #f otherwise.

lua-state?

lua-state? Xprocedure

Returns #t if X is a Lua execution context (as returned by lua-open) or #f otherwise.

lua-thread?

lua-thread? Xprocedure

Returns #t if X is a Lua thread or #f otherwise.

lua-table?

lua-table? Xprocedure

Returns #t if X is a Lua table or #f otherwise.

lua-userdata?

lua-userdata? Xprocedure

Returns #t if X is a Lua userdata object or #f otherwise.

lua-global-ref

lua-global-ref STATE STRINGprocedure
[setter procedure] (set! (lua-global-ref STATE STRING) X)

Gets or sets the global variable named by STRING in the given Lua execution context.

lua-table-ref

lua-table-ref TABLE KEYprocedure
[setter procedure] (set! (lua-table-ref TABLE KEY) X)

Gets or sets the table element in TABLE indexed by the Lua value KEY.

Mapping of Lua results to Scheme values

LuaScheme
nil(void)
numbernumber
booleanboolean
stringstring
light userdatapointer
userdatauserdata record (opaque)
functionprocedure
threadthread record (opaque)
tabletable record

Mapping of Scheme arguments to Lua values

SchemeLua
(void)nil
numbernumber
booleanboolean
string or symbolstring
charstring (holding a single character)
pointerlight userdata
userdata recorduserdata
functioncan not be passed as argument
thread recordthread
table recordtable
vector or a-listtable

Authors

PUC-Rio, packaged as egg by felix winkelmann

License

 Lua is licensed under the terms of the MIT license reproduced below.
 This means that Lua is free software and can be used for both academic
 and commercial purposes at absolutely no cost.
 For details and rationale, see http://www.lua.org/license.html .
 Copyright (C) 1994-2006 Lua.org, PUC-Rio.
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
 in the Software without restriction, including without limitation the rights
 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 copies of the Software, and to permit persons to whom the Software is
 furnished to do so, subject to the following conditions:
 
 The above copyright notice and this permission notice shall be included in
 all copies or substantial portions of the Software.
 
 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE.

Version history

0.3
Ported to Chicken 4
0.2
Lua nil is handled as (void) [suggested by John Cowan]
0.1
initial release

Contents »