3 ms·
Lisp has a rich type system and there is no conceptual problem in having both static analysis and dynamic checks. What happens, especially with classes, is that
by junke 10y ago
Lisp has a rich type system and there is no conceptual problem in having both static analysis and dynamic checks.
What happens, especially with classes, is that you cannot guarantee that your type hierarchy will not be altered at the time you invoke your generic method (highly dynamic classes are a feature too).
But since your whole language is available at compilation time, there is nothing preventing you to define a DSL for a subset of types that are fixed. You could even use compiler macros to deal with trivial cases. Then, you add enough "(declaim (type ...))" directives in your language and augment the optimization settings to allow your implementation to trust declarations without adding dynamic checks.
If you need to have access to more type informations, use the implementation-specific tools to walk your code and define custom transformations (http://www.pvk.ca/Blog/2014/08/16/how-to-define-new-intrinsics-in-sbcl/ http://www.pvk.ca/Blog/2014/08/16/how-to-define-new-intrinsi...) when generating assembly.
The only thing that prevents doing the same work than in C++ is that by default, you can redefine your class hierarchy at runtime: your server is running, you change your class definition and instances of that class have, for example, a new slot, properly initialized. Or, you change the class of your object (square -> rectangle).
- catnaroek 10y ago> What happens, especially with classes, is that you cannot guarantee that your type hierarchy will not be altered at the time you invoke your generic method (highly dynamic classes are a feature too). In other words, the type system is unsound. Which is exactly as useful as having no type system at all. But, anyway, what I asked for is (0) types parameterized by other types [e.g. "dictionary mapping ints to strings"] and (1) dispatch [e.g ither static or dynamic] on parameterized types. How would you solve this challenge? https://news.ycombinator.com/item?id=11592693 https://news.ycombinator.com/item?id=11592693