2 ms·
Yes, this is a somewhat pragmatic approach and perhaps that should have been made clearer. It's necessary to help partially comply with the big spec. As Triti
by piker 1y ago
Yes, this is a somewhat pragmatic approach and perhaps that should have been made clearer.
It's necessary to help partially comply with the big spec.
As Tritium implements more of the spec, the solution is to eliminate the Option return value in the example altogether. The Cursor mis-fires there only due to a disconnect between the glyphs rendered on the canvas and the underlying AST representing those characters. Today, it probably never misses, but due to the complexity of the spec and essentially infinite nesting possible under it, Tritium can't guarantee that yet and so chooses to move the cursor to the top of the document. That's almost certainly better than panicking for the user, and its probability is approaching zero but non-zero. It's getting there.
This approach lets you ship something that is made safe by surfacing errors as a user-visible glitch rather than crashing in release builds.
- vacuity 1y agoI guess I don't understand how much the spec dictates the architecture of Tritium, or the motivation for the Option return type specifically. In any case, it seems like future development will improve upon this. Have fun and good luck!