Closed vtereshkov closed 1 month ago
Local structured constants are especially weird:
fn f(depth: int = 0) {
const a = [2]int{5, 6}
if a[1] > 10 {
printf("OOPS!\n") // OOPS!
}
if depth < 5 {
a[1]++
f(depth + 1)
}
}
fn main() {
f()
}
Without the concept of a pointer to constant (like const T *
in C/C++), structured constants cannot be made truly constant and useful. Go disallows such constants, and so do we.