I understand why the get method of a state has to be contextual - its return value changes depending on where in the document you evaluate it.
But why is the final method of state contextual? Shouldn’t its return value be the same regardless of where I evaluate it - i.e. the state’s value at the end of the document?
Yes, the value of final is the same throughout the document. However, typst compiles your document incrementally, and the value might change across compilations. Therefore, context is required. It tells to the compiler that “This value might change. Don’t cache it without checking.”
However, it still requires context. While its value is always the same within one compilation iteration, it may change over the course of multiple compiler iterations.