3 ms·
It seems to me that you've just invented a static type checker. (Combined with a run-time type checker.) Am I mistaken? I mean, we can argue the semantics of w
by lomnakkus 9y ago
It seems to me that you've just invented a static type checker. (Combined with a run-time type checker.) Am I mistaken?
I mean, we can argue the semantics of what, exactly "static type checker" means, but...
- Guthur 9y agoNot sure it's really an invention, it's been around for awhile. Check any decent common lisp implementation.
- kazinator 9y agoStatic checking doesn't make a "static language". A "static language" occurs when we have a model of program execution that involves erasing all of the type info before run-time. Or most of it. (Some static languages support OOP, and so stuff some minimal type info into objects for dispatch.) Note how above, my expression executes anyway; the checks produce only warnings. The warning for the lack of a binding for the a variable is confirmed upon execution; the non-existence of the slot isn't since evaluation doesn't get that far. If we retain the type info, we have dynamic typing. There is no limit to how much checking we can do in a dynamic setting. The checking can be incomplete, and it can be placed in an advisory role: we are informed about interesting facts that we can act on if we want, yet we can run the program anyway as-is.
- lomnakkus 9y agoThis really sounds like "semantics" to me (not PL semantics! :). For example, these days it's quite possible to ask GHC to defer type errors to runtime. Does that mean that the GHC dialect of Haskell is dynamically typed? This is basically a command line switch away, btw. Retention of type information does not "dynamic typing" make. As a trivial example, consider C++ RTTI. You really have just reinvented static (type) checking and a good runtime. There's no shame in that, but let's not pretend that these are opposing forces.
- kazinator 9y agoC++ RTTI is only for class objects, and only useful when they are manipulated by pointer or reference. I believe I covered that sort of thing with my statement, "Some static languages support OOP, and so stuff some minimal type info into objects for dispatch.". It's a gadget which provides an alternative to the structure of doing everything via virtual functions on a base class reference.
- lomnakkus 9y agoOk, fair enough, but what about e.g. "-defer-type-errors" for GHC? I still think you're just arguing semantics. EDIT: Incidentally, the statically typed crowd can even go the "other way", namely from runtime -> compile time. For example, it's quite possible to derive a static proof/type from a runtime value in e.g. Idris by pattern matching as long as you're meticulous about building up the proof.