lua-users home
lua-l archive

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

On Wed, May 13, 2009 at 3:16 PM, David Manura <> wrote:
> No, this point is unrelated to what tablex does.  I mean that the List
> operation t:map() does not modify t but rather returns a new object.
> This differs from t:reverse(), which modifies t in-place and returns
> itself.

Fine, that makes sense. While we are talking about List, it seems a
good idea to rename things properly and consistently with the rest of
Lua. For example, there is List.delete, which should be just
List.remove, just like the table function, except of course it returns
self for chaining. (a typo makes this function broken at the moment.)

List.index is precisely the same as tablex.find (the latter's name
seems to come from the STL, hence find_if). Having  two names for
exactly the same operation is less than optimal.  ('find' has
precedent in string.find.)

In fact, List.find_if  (or whatever it should be called) is a useful
addition, since there are no existence-with-predicate methods for List
except the relatively expensive List.filter followed by a non-empty

About List.reverse - it does _internally_ create a temporary, but then
copies it back.

steve d.