lua-users home
lua-l archive

Re: table.maxn...

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


On 2015年05月31日, at 8:48 AM, Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:
> 
> A key point of '#' is this:
> 
> t[#t + 1] = v -- add v to the end of the list
> t[#t] -- gives you the last element in the list
> t[#t] = nil -- removes the last element of the list
> 
> Before proposting any other semantics for #, think whether it supports
> these basic list-manipulation operations (insertion, deletion, access
> to last), and whether it can *build* lists containing nils using those
> operations. If not, the new semantics is not solving the problem.
I am quoting this for two reasons:
1) This is a very concise and useful set of statements about #. I wish it could fit in the manual. I will settle for giving it Google juice in the archives.
2) Because these are fundamental operations, I would wish again for this delicious (and perhaps unhealthy) sugar:
longer.name.t[#+1] = 7 ==>
 local _temp
 _temp = longer.name.t
 _temp[#_temp + 1] = 7
We had this in MOO, under the name t[$].
Jay

AltStyle によって変換されたページ (->オリジナル) /