[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Psuedo-proposal: const expression
- From: Dirk Laurie <dirk.laurie@...>
- Date: Fri, 9 Mar 2012 14:25:31 +0200
> const t1 = {'a','b'}
With current Lua syntax, it is possible to write a function
"const" so that
t1={'a','b'}; const"t1"
does what you want.
> t2 = const {'a','b'}
…
> t2[#t2+1]='x' would result in creating a NEW table with contains all the old elements plus a new one. The old table remains unchanged; it is immutable.
Should not `t2[anything]` generate "Attempt to assign to an immutable table"?