lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Apr 18, 2011, at 9:35 PM, David Manura wrote:

On Mon, Apr 18, 2011 at 8:41 PM, Diab Jerius <dj@head.cfa.harvard.edu> wrote:
Lua::API provides Perl bindings to Lua's C-based embedding API [...]
http://search.cpan.org/~djerius/Lua-API-0.04/

Thanks for sharing.

I didn't truly grasp the module until seeing lua.pl [1], so you might
add some very abbreviated version of that to the documentation's
Synopsis.

It allows Perl routines to be called from Lua as if they were written in C,
and allows Perl routines to directly manipulate the Lua interpreter and
its environment.

One important point is that your project is a Perl module that loads
into a Perl interpreter.  It is not a Lua module that loads into a Lua
interpreter.  That is, there is no "luaopen_perlapi", as is the case
in perlembed [2].  ([2] could also be mentioned in your
comparison/see-also section.)

I started something like this a while back, but I lost interest or ran out of time or something:

https://github.com/hoelzro/luaperl

If there's anything in there that can be used to make the bridge go from Lua -> Perl, please feel
free to use it.


This change fixes '=' handling in lua.pl:

@@ -275,7 +275,7 @@

    if ( $firstline && substr($b, 0, 1 ) eq '=')  # first line starts
with `=' ?
    {
- $L->pushfstring( "return %s", substr($b,1));  # change it to `return'
+ $L->pushfstring( "return %s", $b+1);  # change it to `return'
    }

To avoid a symbol-not-found error on Ubuntu, I had to build with the suggested

 perl Makefile.PL LUA_INC=-I/usr/include/lua5.1 LUA_LIBS='-llua5.1'

It might be nice if lua.pl had some way for the end-user to embed Perl
code from the interpreter, maybe by exposing some Lua function that
converts a Perl string to a Lua function.

[1] http://cpansearch.perl.org/src/DJERIUS/Lua-API-0.04/examples/lua.pl
[2] http://thomaslauer.com/comp/Calling_Perl_from_Lua


Attachment: PGP.sig
Description: This is a digitally signed message part