lua-users home
lua-l archive

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


The fruits from a discussion on #lua with Rob Hoelz and Daniel Gruno on
#lua:

foo = t[1, 2, 3] -> __slice(t, 1, 2, 3)
t[1, 2, 3] = foo -> __newslice(t, foo, 1, 2, 3)

Notes:
	* Avoids reuse of __index and __newindex, due to stickyness
	  making it compatible with existing code.
	* Syntax is backwards compatible with existing table
	  deferencing.
	* __index and __newindex implementations can simply call the
	  slice equivalent if they want to share functionality.
	* Slicing either in or out should raise a runtime error if there
	  isn't a suitable metamethod.
	* From a different angle, a table deference is just a function
	  call waiting to be discovered.

Anybody fancy doing a power patch to see how nice/useful/hateful it is
in use?

B.