3 ms·
> Mathematica has lisp essentially as a subset built on top of its rewrite system. Right. > In other words its rewrite system is so powerful that lisp can be
by lispm 12y ago
> Mathematica has lisp essentially as a subset built on top of its rewrite system.
Right.
> In other words its rewrite system is so powerful that lisp can be naturally threaded into it.
a) lots of systems (turing machines, ...) can implement Lisp.
b) it's not that natural in Mathematica. The natural part comes from its symbolic nature. But if you look at the documentation and read about how they implement lexical closures, it's all vague and not that pretty. The implementation actually needs to rewrite variable names, IIRC.
I wonder why their documentation is so vague? They don't want independent implementations of their language?
- taliesinb 12y ago> b) it's not that natural in Mathematica. The natural part comes from its symbolic nature. But if you look at the documentation and read about how they implement lexical closures, it's all vague and not that pretty. The implementation actually needs to rewrite variable names, IIRC. That's indeed what Module does, and it is indeed ugly and slow. When we add parse-time macros it'll be trivial to fix this. For now, many people use Block instead, which does dynamic scoping and is a bit cheaper. I actually really like Block, because it gives you the convenience of a couple of globals that you don't require you to keep passing them along among your backend functions, but they're properly bound to the lifetime of your function (and are re-entrant etc).
- tokipin 12y agoi think you're thinking that Lispification is some kind of goal for the language, but it's not. the lispininess is just one aspect of the language, which is why i think calling it a lisp isn't fair to Mathematica -- it's more powerful/abstract/general than that (in particular because everything is essentially quoted by default - though in their raw forms i suppose both lisp and Mathematica are essentially equivalently capable). the precise character of the lispy aspects of the language (eg the language not "really" having safe-locked closures) is imo just an implementation detail.
- lispm 12y agoMacsyma/Maxima is a computer algebra system written in Lisp, full 20 years older than Mathematica. It implements similar evaluation capabilities. The book Paradigms of AI Programming by Peter Norvig shows how to implement these evaluation strategies in efficient Common Lisp.