lua-users home
lua-l archive

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

It was thus said that the Great Patrick Rapin once stated:
> Hello,
> I have two questions to ask to the entire community. Because for me,
> there is a mystery.
>  - Do you run Lua scripts from within a C or C++ application ?

  Yes.  One of the applications is technically a C++ application, but we
only use C++ in one small section of code as a library we need to call is
written in C++.  The rest of the code is pretty much C.  All other
applications are C.

>  - If yes, what API are you using for it?

  The Lua C API.

> The standard Lua API is powerful and complete, but not really handy.
> You have to load the code (compile), push the arguments, make the
> call, take the results back from the stack, and at most stages check
> whether an error happened and retrieve error message. The sub-API
> d'Arc does not simplify the task neither.

  For me, loading the code (compile) only happens once, and the main logic
of the application is in Lua, so there's only one call I make.  Granted, I
have a bunch of other C code to implement functions available for Lua to
call, and there are only one or two really hairy functions (converting
to/from huge C structures and the hairyness comes from the large amount of
code; otherwise it's pretty straightforward code).

> There are numerous Lua-C++ bindings that ease the process. None of
> them seems popular however.
> I feel frustrated, because I wrote two open-source libraries to simply
> call Lua from C++ [1][2]. LuaClassBasedCall is particularly powerful
> and easy to use.
> It looks like nearly nobody uses it ! And I would like to understand
> why, to decide if I should definitely stop any development on it.

  I don't use it because except for two calls in one application being in
C++ (because the library we need to use was written in C++) the rest of the
code is in C.  The lead developer hates C++ (and it's not like he doesn't
know it---he does.  Perhaps better than anyone else in the office, having
over 20 years experience in it.  I think that's *why* he hates it) and so we
minimize the amount of C++ we use to the bare minimum (if at all).

  -spc (The applications I wrote are used to test call processing features
	our company produces)