|
On Aug 1, 2014 12:06 PM, "Patrick Donnelly" <batrick@batbytes.com> wrote:
>
> On Fri, Aug 1, 2014 at 11:53 AM, Daurnimator <quae@daurnimator.com> wrote:
> > In this case, why even use table.insert, just have `t[#t+1] = v`
>
> I think the point is that if t is an _expression_ and not just a
> variable, then it is annoying/expensive to have it appear twice for a
> simple append. e.g.
>
> foo.bar[#foo.bar+1] = rab
Table appends and pops are common enough to still make me want an analog of MOO's syntax:
foo.bar[#+1] = rab
assert( foo.bar[#] == rab )
foo.bar[#] = nil
A solitary # is defined as taking the length of the subject of the innermost subscript _expression_. It's notionally on the stack anyway.
Jay