[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANNOUNCE] LTN 4 - A thin API for interlanguage working
- From: Jean-Claude Wippler <jcw@...>
- Date: Fri, 9 Feb 2001 16:38:48 -0800
On Fri, Feb 9, 2001, Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br>
wrote:
> http://www.tecgraf.puc-rio.br/lua/notes/ltn004.html
Thank you and Reuben Thomas very much for sharing this. Having gotten a
preview a few days ago, it already helped me create simple wrappers for
Tcl and Python. Early/rough (but working) source and binaries for this
are at http://www.equi4.com/lux/
It turns out to be possible to avoid a special register function by
implementing argument passing and a special "callback" argument. The
argument mechanism also reduces the need to pass scripts around and
compile them on each call.
-jcw
P.S. A Python example from http://mini.net/cgi-bin/lua/25.html
#!/usr/bin/env python
# An example of the Python <-> Lux binding
# 09/02/2001 jcw@equi4.com
import pylux
# Shorthand to run a Lua script with "lux('script')"
def lux(script):
pylux.eval("gv", "dostring", script)
# Shorthand to define a Python proc as callback for Lua
def luxcb(name,func):
pylux.eval("gvc", "setglobal", name, func)
luxGlobals=[]
luxcb("luxAppend", luxGlobals.append)
lux("""
for i,v in globals() do
luxAppend(i)
end
""")
luxGlobals.sort()
print luxGlobals
Note: the first arg to pylux.eval is a string with characters describing
the types of the remaining arguments: g=global, v=value, c=callback.