[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [Proposal] .name global indexing (Was: Re: 'with' statement)
- From: Andrew Cannon <ajc@...>
- Date: Sat, 12 Mar 2016 15:57:00 +0100
On 11/03/16 09:24, Dirk Laurie wrote:
> 2016-03-10 17:55 GMT+02:00 Coda Highland <chighland@gmail.com>:
>
>> At this point you might as well use _.a = 1 and then you no longer
>> even need a with statement.
>
> I use local names consisting of one capital letter instead of _.
> Idioms like "for _,value in pairs(tbl) do" cultivate a habit that
> the underscore is used for return values that one does not
> intend to refer to.
>
Perhaps this syntax could be extended to allow already initialized table members
to be used in initialization later members, a feature which I have sometimes missed:
eg:
local t = {
a = x1 * x2,
b = _.a + 1
}
The '_' in this case would reference the table currently being built.
Andrew