lua-users home
lua-l archive

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


Am 05.06.2014 05:01 schröbte Coda Highland:
On Wed, Jun 4, 2014 at 7:30 PM, Mike Nelson <mikestar1313@gmail.com> wrote:
On 6/4/2014 6:01 PM, Luiz Henrique de Figueiredo wrote:

         load(source,,,MY_ENV)
         first,,third = something()

The idiom in these cases would be

         load(source,_,_,MY_ENV)
         first,_,third = something()

Perhaps it'd be helpful to have a second predeclared local named "_",
as a cheap throw-away variable...

Rather like Go, where _ is predeclared for the same purpose (would be
surprised if they didn't get the idea from Lua). What does everyone think
about also outlawing _ as an rvalue, as Go does?
This would firmly establish _ as a throw-away variable, but is it worth the
internal complexity to enforce it? Perhaps the middle way of predeclaring
but not enforcing is best.

The first of Luiz's examples uses _ as an rvalue.

... and if you swap those two examples you will get weird results, so that would actually be an argument _against_ using `_` as an rvalue (at least for normal code).

And predeclaring is not really useful. Usually you do

    local first,_,third = something()

anyway, and if you predeclare `first` and `third`, you can add `_` to the list there as well ...


/s/ Adam


Philipp