Lisp has the property of being homoiconic, that is, the representation of code used by the language implementation (lists) is also available to, and idiomatically used by, programs that want to represent code for their own purposes.
The other major family of functional programming languages, ML, is based on type theory, which means that the language implementation needs a more complex representation of code, and is also less casual about what you are allowed to do, so typically the internal representation is not available to programs. For example, proof checkers for higher-order logic are often implemented in ML family languages, but normally implement their own type theory system, effectively ignoring the fact that the ML compiler has one already.
Are there any exceptions to this? Any programming languages based on type theory, that expose their code representation for programmatic use?
Take a look at type systems for staged execution (a weak form of metaprogramming), for example, the one used in MetaML language.
Also note that while attractive at first glance, homoiconicity (and metaprogramming by direct AST manipulation in general) turned out to be inconvenient in practice. Take a look at modern systems of macros in Nemerle and an experimental extension of Scala, which both rely on quasi-quotation if I remember correctly.
As for why ML type theory is not reused, here are a few considerations:
The other major family of functional programming languages ... is based on type theory, which means that the language implementation needs a more complex representation of code
I see no reason why this would be true.
If you haven't seen it already, you may be interested in Liskell, which advertises itself as Haskell semantics + Lisp syntax
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With