[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: "John Logsdon" <j.logsdon@...>
- Date: Fri, 18 Sep 2020 18:40:33 +0100
What is the current state of Pallene?
This is meant as a statically typed compiled companion to Lua, written by
the same team that is compatible with Lua, can be called by or call Lua
more efficiently and cleaner than calling C API or FFI. It also shares
garbage collection.
I am keeping an eye on this - I currently am using luajit 2.1.0-beta3 and
luaLanes for the heavy lifing in a large simulation suite.
Compiling core routines that don't need dynamic typing or lazy arguments
etc may be a route to take.
> 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.
>