3 ms·
Type checkers are actually surprisingly easy to write. I recommend learning about unification (in the logic sense), maybe just by playing around with Prolog. Af
by PeCaN 7y ago
Type checkers are actually surprisingly easy to write. I recommend learning about unification (in the logic sense), maybe just by playing around with Prolog. After you understand that I think type checking is rather easy to figure out (it's literally just unification).
- chubot 7y agoI think it depends on whether you have type inference or not. If you have type inference, then it's like unification. If you have explicit type annotations, it's even simpler than that. https://eli.thegreenplace.net/2018/unification/ https://eli.thegreenplace.net/2018/unification/ https://eli.thegreenplace.net/2018/type-inference/ https://eli.thegreenplace.net/2018/type-inference/
- seanmcdirmid 7y agoAnd if you want nominal sub typing, F-bounded generics, and some inference, things get really fun.
- rurban 7y agoNominal subtyping is trivial and unsafe. The fun starts with structural subtyping.
- seanmcdirmid 7y agoNominal sub typing is hard from trivial and calling it unsafe is non-sensical. Structural subtyping yields poor error messages and does not support encapsulation very well, especially if you also want separate compilation.