[Proposal] @table and @function (Was: [Proposal] .name global indexing (Was: Re: 'with' statement))
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: [Proposal] @table and @function (Was: [Proposal] .name global indexing (Was: Re: 'with' statement))
- From: "Soni L." <fakedme@...>
- Date: 2016年3月12日 13:31:48 -0300
On 12/03/16 01:02 PM, Rena wrote:
On Mar 12, 2016 9:57 AM, "Andrew Cannon" <ajc@gmx.net
<mailto:ajc@gmx.net>> wrote:
>
> On 11/03/16 09:24, Dirk Laurie wrote:
> > 2016年03月10日 17:55 GMT+02:00 Coda Highland <chighland@gmail.com
<mailto: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
>
>
I think `b = t.a + 1` would be more natural, but I don't know how
doable it is.
local t{
}
vs
local t = {
}
It does generate ambiguity when used inside the table (function call f{}
or table t{}) tho... And cannot be used as part of a return... Hmm...
@table and @function ("top level table constructor" and "current
function" respectively) could work instead, @table would be done at the
parser level and @function would be done at the bytecode level[1].
[1]: https://github.com/SoniEx2/sexlua/blob/master/FEATURES.md scroll
down to self-referential functions
--
Disclaimer: these emails may be made public at any given time, with or without reason. If you don't agree with this, DO NOT REPLY.