lua-users home
lua-l archive

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



for k, v in next, t do

Yes -- it's true, if you stare at it too long (as I certainly have, at this point), it becomes very hard to come up with a syntax that seems much better than the existing one.  I don't think  'for k,v in next,t' is really any clearer than the normal pairs boilerplate, but, I also don't find 'for k,v == t' particularly clear (or any other non-breaking token substitution that I can think of). 

I do think Lua 4's iteration syntax is generally clearer than Lua 5's -- but, if you bring back Lua 4's table iteration while trying to keep Lua 5's generic for syntax intact (as John did) it invites all sorts of messes with metamethods.  Might be best to just leave well enough alone.  

While your at it, make me named arguments with default values that mirrors the syntax sugar for calling a function with a single table

Now, here I'm well and truly lost.  Though I think this is intended as an example of something *not* to do, so perhaps it doesn't really require clarification :)  

-Sven