[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: How to acquire the name of the variables passes to the self-defined C function which has been successfully set by lua_register()?
- From: Sudipto Mallick <smallick.dev@...>
- Date: Fri, 22 Jan 2021 08:58:38 +0530
> It's a solution. But, maybe, not a good one.
>
> You see, the parameters passed to the C function are tables already,
> e.g:
>
> carState = {};
> personState = {};
> roadState ={};
>
> calc(carState, personState, roadState)
You see, we can not read your mind. But from the example you have
provided, I think the following can be done:
state = { car = {}, person = {}, road = {} }
-- ... initialize state ...
calc(state)
> It's not a good idea to replace the aforementioned code snippet with
> another one like this:
> calc({`carState`=carState, 'personState'=personState,
> `roadSate`=roadState).
>
> The aforementioned tables(i.e carState and etc) are already complicated.
> It's not a good idea to put these tables into another table.
That is up to you. When you are writing code, you decide how to
structure your code and data.
> One more question, is there a clerical error in your last email?
> I think it should be foo({a = 10, b= 129}) instead of foo{a = 10, b =
> "meh"}.
In lua, when the first and only argument to a function is a table
constructor or a string literal, you can drop the parenthesis.
Question to others: when it was introduced in lua?
--Sudipto Mallick
- References:
- How to acquire the name of the variables passes to the self-defined C function which has been successfully set by lua_register()?, 孙世龙 sunshilong
- Re: How to acquire the name of the variables passes to the self-defined C function which has been successfully set by lua_register()?, Sean Conner
- Re: How to acquire the name of the variables passes to the self-defined C function which has been successfully set by lua_register()?, 孙世龙 sunshilong
- Re: How to acquire the name of the variables passes to the self-defined C function which has been successfully set by lua_register()?, Sean Conner
- Re: How to acquire the name of the variables passes to the self-defined C function which has been successfully set by lua_register()?, 孙世龙 sunshilong
- Re: How to acquire the name of the variables passes to the self-defined C function which has been successfully set by lua_register()?, Sean Conner
- Re: How to acquire the name of the variables passes to the self-defined C function which has been successfully set by lua_register()?, Sudipto Mallick
- Re: How to acquire the name of the variables passes to the self-defined C function which has been successfully set by lua_register()?, Sean Conner
- Re: How to acquire the name of the variables passes to the self-defined C function which has been successfully set by lua_register()?, Sudipto Mallick
- Re: How to acquire the name of the variables passes to the self-defined C function which has been successfully set by lua_register()?, 孙世龙 sunshilong