Re: [ANNOUNCE] LTN 4 - A thin API for interlanguage working

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: [ANNOUNCE] LTN 4 - A thin API for interlanguage working

Jean-Claude Wippler
On Fri, Feb 9, 2001, Luiz Henrique de Figueiredo <[hidden email]>
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 [hidden email]

  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.