lua-users home
lua-l archive

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




On Feb 20, 2008 4:33 PM, Daniel Stephens <daniel@danielstephens.com> wrote:
Ideally there could be a new multi-arg indexing syntax with its own pair
of metamethods, allowing for both multiple arguments **AND** multiple
assignments?

Something [...] Where matrix[1, 2] = 8.1, 0.0, 7.2; Becomes _setmulti(matrix, 2, 1, 2, 8.1, 0.0, 7.2)

What I dont know (since I've not played with any of them) is whether any
of the existing language extension mechanisms provides the framework
required for this without modifying the language directly.

You can, and with metalua it's fairly easy. That's essentially what does my code snippet above (I've left the multi-assignment matter unaddressed, but that's a 3-lines modification). I'd only advise you to use a syntax that don't overlap the regular "[expr]" one, for modularity reasons.