[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: get_local() and "(for index/limit/stop)"
- From: Rici Lake <lua@...>
- Date: Sat, 18 Sep 2004 08:29:33 -0500
On 18-Sep-04, at 6:08 AM, Adrián Pérez wrote:
Moreover, if you recognize "_" as such, you can make optimizations to
bytecodes, for example if you do:
_, a = my_function()
The compiler may skip generating bytecodes for the first argument,
thus gaining a bit in speed. Not a big gain, but it worths if you use
"_" a lot (using "_" is quite usual in functional programming).
That is probably more useful in functional languages with lazy
evaluation; my_function() might not need to calculate its first return
value. But in Lua, it is going to calculate it anyway; the only cycles
saved would be a load/store.
In any event, the compiler should not need clues like this. It is easy
enough to tell if the value of a local variable is not going to be
used, regardless of its name. That is usually a programming error, of
course: my Lua linter has a specific hook in it to avoid flagging
unused local _'s in order to allow this idiom.
Rici.