[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: need help: some features of Lua don't fit well together
- From: Konstantin Osipov <kostja@...>
- Date: Tue, 14 Apr 2015 19:11:59 +0300
* Jerome Vuarand <jerome.vuarand@gmail.com> [15/04/14 18:59]:
> Why do you need to distinguish the case when a Lua table is actually
> an array? If you can store an arbitrary map, Lua arrays are just a
> special case of that. In other words:
>
> function convert_stack_to_set(...)
> local set = {}
> local n = 1
> for each stack value do
> set[n] = value
No, set elements must be lists, i.e. sequences of fields.
Here we may break this rule if the value is a map or a scalar.
We could convert each stack element to a list with one field, but
then there would be no way to return a list with many fields,
even if the user wanted to do so.
> n = n + 1
> end
> set.n = n -- if you care about trailing nils
> return set
> end
--
http://tarantool.org - a NoSQL database in a Lua script