Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

So how would you compile code which contains a call to a method which is only defined at runtime?


In a dynamic language, everything is only defined at runtime.

Given that, a sketch of a statically-typed system would be something like... At the time a definition is added to the environment, you type check against known definitions. Future code can change implementations, as long as types remain compatible. (Probably invariantly, unless you want to include covariant/invariant annotations in your type system...)

This doesn't change that much about a correct program in a dynamic language, except that it may provide some additional ordering requirements in code execution - all the various method definitions must be loaded before code using them is loaded. That's a bit more strict than the current requirement they the methods must be loaded before code using them is run. But the difference would be pretty tractable to code around.

And in exchange, you'd get immediate feedback on typos. Or even more complex cases, like failing to generate some method you had expected to create dynamically.

Ok, I can actually see some appeal here, though it's got nothing to do with monkey-patching.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: