lua-users home
lua-l archive

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


> (Just out of interest, is the byte-code compiler intelligent enough to
> optimise 'while true do'... into a noop? Because it's a very common idiom.)

Definitely. See for yourself with
	echo 'while true do end' | luac -l -p -

This will print

	1	[1]	JMP      	-1	; to 1
	2	[1]	RETURN   	0 1

Note that there is just a jump instruction, no test.

The code generator does several other optimizations like that.
--lhf