lua-users home
lua-l archive

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


Why do not add slicing in the next release of Lua ?
It could be for example :

	tab[i:]  equivalent to tab[i,false] or tab[i,nil]
	tab[:j]  equivalent to tab[false,j] or tab[nil,j]
	tab[i:j] equivalent to tab[i,j]

And if the metatable __index is defined, it would be respectively
equivalent to :

	metatable(tab).__index(tab, i, false)
	metatable(tab).__index(tab, false, j)
	metatable(tab).__index(tab, i, j)

And also create the _index metamethod in the string module, so this
could be used with strings. Then I could have instead of str:sub(1,2)
str[1,2] ... and instead of str:sub(2,2) str[2].

Any toughts about it ?
Mildred       <> <>
Clef GPG :    <hkp://> ou <>
Fingerprint : 197C A7E6 645B 4299 6D37 684B 6F9D A8D6 [9A7D 2E2B]