lua-users home
lua-l archive

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


Op 20 februari 2012 08:56 schreef steve donovan <steve.j.donovan@gmail.com> het volgende:
 
The example was motivated by a gap in ml: there are bulk operations
for setting and getting multiple keys but nothing for removing
multiple keys.

Iterating table.remove is horribly inefficient.  Reusing names already in a
standard library is bad, I know, but if it is downward compatible, why not?
We could have ml.remove(tbl,start,count), count defaulting to 1.  Or
ml.remove(tbl,start,stop), stop defaulting to start, if that is deemed to
be more Luatic.

There is a good case for having bulk removal in ml since efficient Lua code
is not all that simple:

   for k=start+count,#tbl do tbl[k-count]=tbl[k] end
   for k=#tbl,#tbl-count+1,-1 do tbl[k]=nil end
 
(And I'm still having cognitive dissonance from List vs Array)  

Now that the Triumvirate has settled on "sequence" in the 5.2 manual,
Sequence seems indicated.
 
What about moving mlx's List into ml, plus a Set class?

Thus making some room in the top-30 for other stuff, since Sequence and Set
counts only as one each!

Dirk