Migrate let to const for constants
Sometimes we may have a need to use a FixedArray as a constant, but it is not allowed now. What should we do about it.
// not allowed
const GDOUBLE_POW5_INV_SPLIT2 : FixedArray[UInt64] = [
1, 2305843009213693952, 5955668970331000884, 1784059615882449851, 8982663654677661702,
1380349269358112757, 7286864317269821294, 2135987035920910082, 7005857020398200553,
1652639921975621497, 17965325103354776697, 1278668206209430417, 8928596168509315048,
1978643211784836272, 10075671573058298858, 1530901034580419511, 597001226353042382,
1184477304306571148, 1527430471115325346, 1832889850782397517, 12533209867169019542,
1418129833677084982, 5577825024675947042, 2194449627517475473, 11006974540203867551,
1697873161311732311, 10313493231639821582, 1313665730009899186, 12701016819766672773,
2032799256770390445,
]
The following behavior is also not allowed, but I believe that compile time calculations can be performed on the output of pure functions
pub const NOT_A_NUMBER : Double = 0x7FF8000000000001L.reinterpret_as_double()
Sometimes we may have a need to use a FixedArray as a constant, but it is not allowed now. What should we do about it.
// not allowed const GDOUBLE_POW5_INV_SPLIT2 : FixedArray[UInt64] = [ ]
This should be allowed as this is defined in https://github.com/WebAssembly/gc/blob/main/proposals/gc/MVP.md#constant-expressions @Guest0x0 @Yu-zh ?
Sometimes we may have a need to use a FixedArray as a constant, but it is not allowed now.
We should introduce a new primitive type like ReadOnlyFixedArray in the compiler for this.
This should be allowed as this is defined in https://github.com/WebAssembly/gc/blob/main/proposals/gc/MVP.md#constant-expressions @Guest0x0 @Yu-zh ?
This is not relevant. Constant expressions in Wasm is used for initialization of globals. It has no indication on the mutability of the data.
The following behavior is also not allowed, but I believe that compile time calculations can be performed on the output of pure functions
pub const NOT_A_NUMBER : Double = 0x7FF8000000000001L.reinterpret_as_double()
I thought about it again, and it may be quite demanding to achieve such a situation, but I don't know if anyone has any effective solutions?
Another small issue is that we have many pub constants that may not be capitalized, but now our constants require capitalization, which may result in a large number of API migrations. Should we bear this cost?
cc @peter-jerry-ye @Yu-zh @hackwaly
Currently the pub let are mostly min / max values and nan / +-inf. The PI has been migrated.