4 ms·
> But that's wrong. If I have strong dynamic typing and the program never goes to that part of the code, I don't get an error. Exactly. > It will still compla
by Dewie 13y ago
> But that's wrong. If I have strong dynamic typing and the program never goes to that part of the code, I don't get an error.
Exactly.
> It will still complain if you muck things up when you type them into the repl. Dynamically.
Yeah, because it's a REPL so it has to evaluate every line of code that you give it. How does that work when you have code as a file and you run the main function of that file? You would have to run every line of the code. So what about code paths that are not taken? Do you just give enough input data that eventually all code has been run through? But then you 're not really running the main function, you're running all the code of that program has, with whatever results and output that that might give. Obviously I'm not talking about Haskell here, which already has a static type system.
Is your claim that you don't need a compiler to do type checking? Well, yeah, since type checking is not part of the source code translation. But it often said to be part of a compiler since it it often is often part of the semantic analysis phase. But if you have an interpreter you wouldn't really have a compiler as in a program translator.
I interpreted 'The interpreter can just complain to you when you try to run it.' as "complain to you as you are running it". Not "complain right before you run it".
- iopq 13y agoNo, you just run the static type check on the entire program. Like you run the Haskell REPL on a file and it type checks it for you and executes the main. It can just do this in RAM without generating an executable file. Yes, it will technically complain before you even run it. Because it will first analyze it and only then run it if it type checks. The entire file, not just the reachable parts.