lua-users home
lua-l archive

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


> 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