3 ms·
Very nice! But is Python the right choice for this? It seems like the macro rewriting abilities of Lisp (especially Racket) would be a perfect fit for this proj
by mruts 7y ago
Very nice! But is Python the right choice for this? It seems like the macro rewriting abilities of Lisp (especially Racket) would be a perfect fit for this project. And he's already using S-exps, so why reinvent the wheel?
- fdej 7y agoThat's a good question. The S-expressions are actually a trivial part of the project right now, because there is no symbolic computation going on, just composing S-expressions without any form of rewriting and then generating the website from the final S-expressions. So there is wheel reinvention, but it's just a few minutes of work :) Python happens to be convenient for the website generation, plus I use it because I have other tools in Python. The code is a bit of a mess right now, but I will clean it up gradually. Later on I plan to make the formula database itself available in some language-agnostic form, with the idea that you could interface it from any programming language or computer algebra system you like. Both Python and Julia are on my radar. And Racket would be quite nice too, since I agree that it's a very nice language for this kind of thing!
- HelloNurse 7y agoLisp macros are meant to rewrite S-expressions that represent source code in controlled, predictable and well-behaved ways, whereas S-expressions in Fungrim represent data and they can be transformed in generic and aggressive ways to deduce something useful. Different purposes, with different needs and only a limited technology overlap (the theory of how to maintain program correctness through transformation is related to the theory of how to squash hidden assumptions and subtle type mismatches in algebraic formulas).
- lispm 7y ago> Lisp macros are meant to rewrite S-expressions that represent source code 'source code' is slightly misleading, since the s-expressions don't need to be valid source code. What's valid is only limited by what the macro wants do. If a macro accepts the s-expression form, then it is valid. For example that means that the macro form itself does not need to be parseable to an AST by an existing language grammar. The macro itself can parse the s-expression in arbitrary ways. If data is source for the macro, then it may do something with it...
- mruts 7y agoI think you misunderstand the genericicity of macros in Lisp. Macros take one or more S-exps and return and S-exp. nothing more, nothing less. There’s no reason why macros need to generate valid code. Though in Lisp, it’s pretty easy to make any code you want valid.