2 ms·
> A compiled language cannot know what the value of a variable is at compile time, unless the variable is a constant. This statement is false. I recommend read
by curryhoward 10y ago
> A compiled language cannot know what the value of a variable is at compile time, unless the variable is a constant.
This statement is false. I recommend reading about dependent types, which enable exactly what you claim is impossible.
It's true that in every mainstream language, the type system is not powerful enough to reason about types that "depend" on values, such as the type of MxN matrices, sorted lists, prime numbers, etc. But don't limit your sense of what is possible by your experience with mainstream languages; most have rather limited type systems compared to what we know is possible in theory.