top | item 31115745

(no title)

smu3l | 3 years 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?

discuss

order

ledauphin|3 years ago

static 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|3 years 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.

reikonomusha|3 years ago

Python is compiled, just not to machine code.