[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: What languages could be used to implement the functions to be invoked by Lua?
- From: 孙世龙 sunshilong <sunshilong369@...>
- Date: Fri, 18 Sep 2020 20:39:45 +0800
Hi, Francisco Olarte
Thank you for your clarification.
>Regarding C++, I do all my modules using it. I embed the modules and
>do not use dynamic loading.
Could you please explain that in more detail for me?
Thank you for your attention to my question.
Sunshilong
On Fri, Sep 18, 2020 at 5:35 PM Francisco Olarte <folarte@peoplecall.com> wrote:
>
> On Fri, Sep 18, 2020 at 10:59 AM 孙世龙 sunshilong <sunshilong369@gmail.com> wrote:
> > As per the documentation(https://www.lua.org/pil/24.html), which says
> > that[emphasise mine]:
> > At the same time, a program that uses Lua can register new functions
> > in the Lua environment;
> > such functions are implemented in C (or **another language**) and can
> > add facilities that
> > cannot be written directly in Lua.
> > My question is what other languages?
> > Can these functions be implemented in C++? If not, is there any
> > workaround to achieve this goal?
> > If you could give some simple examples, that would be great.
>
> Once compiled, everything is machine code. You only have to worry
> about the calling convention ( where are parameters passed and how are
> values returned ). Also, Lua uses some C-oriented data ( like null
> terminated strings ), so your language must be able to manage them,
> but nearly every language can.
>
> Regarding C++, I do all my modules using it. I embed the modules and
> do not use dynamic loading, so I do not care about naming ( but using
> extern "C" you can easily do it. I just use static functions in my
> clases ( I register a static function in lua, this function gets the
> object pointer, if needed, and calls a normal method, so I can keep
> everyting private if I like to ).
>
> Any language which can call C would do. If your language as bindings
> for any of the popular libraries, be it xml, graphics, sound, whatever
> chances are it can call ( to use the api functions ) and be called by
> ( to register extensions ) lua without problem.
>
> Francisco Olarte.