| ▲ | steeleduncan 5 hours ago |
| const MAX: u32 = 100; // Compile-time constant
let x: u32 = 10; // Cannot be changed
If x cannot be changed, how does it differ (meaningfully) from a compile time constant in a safe language, ie in a case of no raw pointers |
|
| ▲ | v0id_isgood 5 hours ago | parent | next [-] |
| const can be used in places that need a compile-time-known value (like a fixed array size). let can't, even if it obviously holds a fixed number. |
| |
| ▲ | bramadityaw 2 hours ago | parent [-] | | isn't there a way to infer that from context? like if the variable is declared with the Comptime role. Some guy said that the const keyword was a mistake C made that is then blindly followed by its successors. |
|
|
| ▲ | 4 hours ago | parent | prev [-] |
| [deleted] |