lua-users home
lua-l archive

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


> No, they generate essentially the same code, except for when the values
> are assigned to x and y:
> 
> [...]

In some cases the multiple assignment can generate more instructions,
to avoid colisions:

i, a[i] = 3, 4      -- a and i local

	1	[2]	LOADK    	2 -1	; 3
	2	[2]	SETTABLE 	0 1 -2	; - 4
	3	[2]	MOVE     	1 2

i = 3
a[i] = 4

	1	[4]	LOADK    	1 -1	; 3
	2	[5]	SETTABLE 	0 1 -2	; - 4


Nonetheless, usually those are the cases where it is worth paying the
price ;)

-- Roberto