lua-users home
lua-l archive

Re: __index returns truncated to one, why?

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


On 10/04/2014 14:20, Sean Conner wrote:
It was thus said that the Great Thiago L. once stated:
I just realised this could be another case for my old suggestion [1]
about '...' as a suffix operator which means, explicitly, "do not
truncate this list of values". My original suggestion was for function
call arguments, so:
 func(a()..., b, c)
...would not truncate the return values of a(), as it normally would.
But another case could be for this case, so:
 local a, b, c = t[1]...
	t = { 'one' , 'two' , 'three' }
	local a, b, c = t[1]...
 a == 'one', that's fine.
 What does b and c equal?
Whatever ({mt.__index(1)})[2] and ({mt.__index(1)})[3] would be...
 Well, two things:
	1) the syntax is t[1]... (note trailing dots) which is meant to
	 indicate multiple values starting at the given index (from what I
	 understand the proposal to mean).
No, it's meant to turn "return (h(table,index))" into "return h(table,index)"
	2) there is no metatable.
 Another question:
	t = { one = 1 , two = 2 , three = 3 }
	local a,b,c in t['one']...
 What does b and c equal?
 -spc

AltStyle によって変換されたページ (->オリジナル) /