4 ms·
What's lexical typing?
by eru 12y ago
What's lexical typing?
- btilly 12y agoI would assume from context, it is the ability to declare a variable in a lexical scope to have a specific type in that scope. With static typing you would then have the ability to catch use of that variable with the wrong type and make that a compile time error. That said, I believe that pylint could statically catch some of the type errors that are being referred to.
- candeira 12y agoI may have made this term up myself; I am on the go and can't check it. As I use the expression "lexical typing", it means that the type of a variable can be ascertained from examining the text of the program, without needing to run it. Python is strongly typed, but dynamically typed: you can only know for sure the type of a value by checking the value at runtime. This by analogy with "lexical scoping", where you know where a certain name will be bound just by looking at the program's text, while with dynamic scoping, the stack is what determines where a variable is bound, and you can only know about it at runtime. I guess I should have said "static typing". I probably made the mistake because lexical scoping is also called static scoping, and I was writing in a hurry.