lua-users home
lua-l archive

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


I'll try to answer all the comments at once.

First, I would not make a distinction between tuple and lists. Both 
represents the same thing.

> If you have a good case, could you share that with us?

As far as I know, it is not possible to know from a function return value 
how many values where just returned. You can pack them and unpack them but 
it is not possible to know in advance how many of them are there. In my 
opinion, the return value of a function in lua is a kind of hidden list.

Ok, I admit returning a variable number of objects in a function is a bad 
practice, but what I see is that there seem to be a few places in lua where 
list would make sense but are not used because they are not available. I am 
not familiar enough with lua yet to point all of them out though. But the 
pack/unpack thing keep bothering me. It is really build a list object but 
don't tell them.

> Something, 
> where having a dedicated list object would really boost the performance
> of the application?

I believe that you can apply some optimisation for lists, that you can not 
get from tables, because a list is a more simple type. While tables do have 
a good emulation for lists, they remain tables and can only be optimised as 
tables. In cases where you only need a list and not a table, you would 
probably get a performance boost.

For example, if you have a list of 10000 items, a lua table is going to 
store the keys 1 to 10000 and to store the values too. A list would only 
store the values. Iterating upon such a list is also quicker than over the 
equivalent table because a double-linked list is easier to iterate over 
than a list of hash.

Another thing about lists is that it is a very common and easy to understand 
type. People having little experience in programming can understand what a 
list is very quickly. A map/hash/table is more difficult to grab.

Another thing that I dislike about table as lists is that when you do:
t = {1,2,3,4,5,6}, lua does a lot of things under the table to make it look 
like a list. This is not good because it adds complexity to a simple 
expression that nobody expect to lead to complex situations.

	cheers,

	Philippe

-- 
An open source OS for contactless Smart Cards
http://www.jayacard.org - Jayacard