lua-users home
lua-l archive

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


Michael Roth wrote:
[...]
Maybe, 'first' should be really called 'head'.

I'm really not keen on the idea of cluttering up the global namespace with lots of new functions; it's full enough as it is.

As this is a low-level, fundamental feature, it does make sense to have it part of the syntax rather than a library extension... is there any reason why the [] operator can't be extended?

 (...)[1] --- pick the first element
 (...)[-1] --- pick the last element
 (...)[4, 3] --- pick a range of elements

The (...) could be made implicit without introducing ambiguities, which means that you can do things like...

 for i=1, 10 do
   print([i])

Which, you'll have to admit, is slightly neater than using a function, as well as making it more obvious that you're doing something strange.

--
[insert interesting .sig here]