Hacker News new | past | comments | ask | show | jobs | submit login

That's... exactly the kind of thing a type system is intended to stop you from doing.



Is it? I think it's fairly uncommon to use types to enforce correct units in calculations, and you need a pretty sophisticated type system to be able to do it.

I'm not saying it's a bad idea, just that it's not really a core application of type systems in real-world programming practice.


Sure, but the general idea that you should disallow undefined operations are a core application of type systems.

You don't need too advanced of a type system to implement what you're talking about. With the caveat that doing it in Java would make the code tedious to write ;-).




Consider applying for YC's Summer 2025 batch! Applications are open till May 13

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: