4 ms·
I'm not clear: is typestate a compile time or run time guarantee? [Edit] That is, is the guarantee implemented at compile time, noting violations similarly to s
by thyrsus 15y ago
I'm not clear: is typestate a compile time or run time guarantee?
[Edit]
That is, is the guarantee implemented at compile time, noting violations similarly to syntax violations, or does it generate "invisible" code that performs runtime checks which can throw something similar to exceptions?
- cwp 15y agoA bit of both, actually. It's mostly compile-time checking, but you can also write assertions about the typestate of a particular variable. The compiler generates code to check the actual values at runtime - if the assertion fails, the program is aborted. The really cool bit is that the compiler can take the assertions into account when compiling code that follows the assertions.