[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Standard Libraries: (was: and Lua marches on)
- From: steve donovan <steve.j.donovan@...>
- Date: Fri, 18 Dec 2009 08:38:12 +0200
On Fri, Dec 18, 2009 at 5:43 AM, Mark Hamburg <firstname.lastname@example.org> wrote:
> split should probably return an iterator and we should have a collect function. But then one needs to worry about whether the iterator for split just returns a series of strings or whether it returns an index and a string so that collect is compatible with ipairs.
There's always that design choice; working with iterators is more
general. Which is why I'm tending towards:
map(fun,pairs(t)) or map(fun,ipairs(t))
Completely clear and explicit, like the for-in loop.
And chains of 'sequence' operations are a powerful concept.
Most implementations of split() tend to return a list (the one in
Sputnik bit me because it returned unpacked values; expectations!).
It is easy to to turn that into a standard iterator, so I'd vote for
collect() would be useful, I've overloaded copy() to either take a
table or a sequence, which is probably not clear. collect(lfs.dir
'.') makes an array of the contents of a directory, but what does
collect(ipairs(t)) do? Create an array of key-value pairs?
> But overall, I like the notion of trying to hone in on a standard library for Lua. Before diving too deep, however, it's probably worth establishing both process and goals.
One of the goals would be to provide a well-written and documented
core of functions which fulfill the common needs of Lua programmers.
The current process is asking people their opinion on this list ;)
Making a library is a small-group job, but that group has to have
buy-in, and some means to solicit contributions and feedback