lua-users home
lua-l archive

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


On Wednesday, June 04, 2014 10:01:13 PM Luiz Henrique de Figueiredo wrote:
> The idiom in these cases would be
> 
> 	load(source,_,_,MY_ENV)
> 	first,_,third = something()
> 

Of course. But if the lines were reversed you'd have a problem. I'm sure 
everyone knows not to trust `_` as a rvalue and explicitly writes `nil`. If 
`_` were reserved as a placeholder name then as a lvalue it's immediately 
forgotten, and as a rvalue it evaluates to `nil`. But then what's the 
difference between this and what Dirk and I suggested with empty items in the 
comma list? It's not merely syntactic sugar because you're indicating the 
value is going to be discarded immediately. The compiler then knows it doesn't 
need to keep that register slot around unlike the `local _`. Not to mention 
gcing the value earlier.

I'm pretty sure there are sources out there that use `_` for something other 
than a placeholder lvalue. Any change to how it's handled would break 
someone's code.

Alternately allow `nil` as a lvalue that acts as the bit bucket.

-- 
tom <telliamed@whoopdedo.org>