3 ms·
What is the precise definition of static typing? Both the article and many comments in this thread refer to static typing or static type hints in Python. But as
by smu3l 4y ago
What is the precise definition of static typing? Both the article and many comments in this thread refer to static typing or static type hints in Python. But as I've always understood it, static typing means that types are checked and enforced at compile time. And if python is not compiled, the notion of static typing in python does not make sense. So do I have it wrong? Or is the term ambiguous?
- ledauphin 4y agostatic in this case can be understood to mean simply "prior to (or separate from) runtime". In other words, it's based on what you can check _without_ running the code. It's worth noting that nearly every statically-typed language currently in existence has two separate "type systems" - the static type system which is the formal type system offered to the programmer, plus a runtime type system enforced, at minimum, by the processor (e.g. you cannot divide by 0) that is ultimately different from the static type system. The 'question' in most cases is "how closely does the runtime type system match the static type system?" In many if not most languages, the answer is "not very".
- tialaramex 4y ago> It's worth noting that nearly every statically-typed language currently in existence has either two separate "type systems" Either that or... ? You should probably complete this thought. I don't think the distinction you've claimed make much sense, but perhaps you had an alternative which you just never explained.
- ledauphin 4y agothat was a typo - no "either" was intended. I've amended the original. not sure if that will help clarify?
- reikonomusha 4y agoPython is compiled, just not to machine code.