lua-users home
lua-l archive

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



It really is a great syntax,  and this example has won me over.  I.e.
new features should not be one-trick ponies; they should enable new
classes of tricks.

Tragically, there's a bug in my example.  I didn't notice the '.' in Jay's 'pl.utils'.  One could use a string conversion convention to write a version of _IMPORT that would allow

local pl_utils in _IMPORT  ==>  local pl_utils = import 'pl.utils'

But I'm not certain it's a good idea.  Still, Peter's table unpack is an excellent syntax.  And an unexpectedly powerful one.  For example, we can use a similar __newindex trick to set a large collection of variables to the same value.

a00,b00,a10,b10,a11,b11,t0,t1 in generate(0)

This means that in many situations, table unpack can actually fill the same role as assignment chaining -- and unlike assignment chaining, it's quite compatible with Lua's existing syntax.

-Sven