diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-05-17 11:11:44 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-05-17 11:11:44 -0300 |
| commit | d9f40e3f6fb61650240c47d548bee69b24b07859 (patch) | |
| tree | ab01022b3e3bc6bdb800423c97095a9423e0a798 /testes/math.lua | |
| parent | 347d6961ac14213264c7176e3d125c9ba8475b01 (diff) | |
| download | lua-d9f40e3f6fb61650240c47d548bee69b24b07859.tar.gz lua-d9f40e3f6fb61650240c47d548bee69b24b07859.tar.bz2 lua-d9f40e3f6fb61650240c47d548bee69b24b07859.zip | |
First implementation for 'const' variables
A variable can be declared const, which means it cannot be assigned to,
with the syntax 'local <const> name = exp'.
Diffstat (limited to 'testes/math.lua')
| -rw-r--r-- | testes/math.lua | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/testes/math.lua b/testes/math.lua index b010ff6c..c45a91ad 100644 --- a/testes/math.lua +++ b/testes/math.lua | |||
| @@ -3,10 +3,10 @@ | |||
| 3 | 3 | ||
| 4 | print("testing numbers and math lib") | 4 | print("testing numbers and math lib") |
| 5 | 5 | ||
| 6 | local minint = math.mininteger | 6 | local <const> minint = math.mininteger |
| 7 | local maxint = math.maxinteger | 7 | local <const> maxint = math.maxinteger |
| 8 | 8 | ||
| 9 | local intbits = math.floor(math.log(maxint, 2) + 0.5) + 1 | 9 | local <const> intbits = math.floor(math.log(maxint, 2) + 0.5) + 1 |
| 10 | assert((1 << intbits) == 0) | 10 | assert((1 << intbits) == 0) |
| 11 | 11 | ||
| 12 | assert(minint == 1 << (intbits - 1)) | 12 | assert(minint == 1 << (intbits - 1)) |
