Hacker News new | past | comments | ask | show | jobs | submit login
Lisp implementation in GNU make (github.com/shinh)
98 points by aerique on Sept 15, 2015 | hide | past | favorite | 16 comments



I'd love if make was less capable of implementing a toy Lisp and more capable of quoting characters. Like quoting a left paren. I mean, at all.


I think we should acknowledge how impressive it is implementing a Lisp of all languages in a language that doesn't let you easily quote parens!


IN GNU make there's \( , $(\() and lparen := \( ... $(lparen) .


\) didn't work for me (may depend on the context, don't know), and some Google searches and Stackoverflow answers later I settled for LEFTPAREN:=) and $(LEFTPAREN)


I love the abuse of turing complete tools. It's a weird perversion that I'm starting to appreciate more.


This reminds me of MAL [1], which stands for "Make A Lisp" or Make, A Lisp" depending on whether you're talking about the whole project or just the make version. It branched out into being implementations of a lisp in over two dozen languages, with instructions to help in writing your own. I was working on a haxe version before my motherboard recently bit the dust.

[1] https://github.com/kanaka/mal


And yet there is Racket which is 100% making your own language based on Lisp. Serious question. Why is there mal when we already have Racket?


I think there may be a misunderstanding here - mal is not the language you make the lisp (or any other language) in, it is the language you are implementing. Indeed, there is an implementation in Racket, and even in mal itself.

The point of mal is to guide an implementer through the steps necessary for making an interpreter using a language they are comfortable in. It gives some insight into how various constructs are implemented, such as closures and tail call optimization. The purpose is not so much to make a lisp-like language (although that is the outcome), but to learn what goes into making an interpreter for one - especially when you can't lean on the constructs that already exist in the host language.


A while back I implemented Conway's Game of Life in make... by writing it in a custom high level language and then writing a compiler into GNU Make script:

http://cowlark.com/2013-10-19-insane-make

I also wrote an arbitrary precision maths library, because make doesn't support arithmetic. I got as far as addition, subtraction and multiplication before coming to my senses.


For more wild things you can do in GNU make by pushing the internal language: http://gmsl.sf.net/ And also: https://www.nostarch.com/gnumake

I like they way they've done the arithmetic.


Somewhat hidden in the readme: A link to https://github.com/google/kati which is apparently much faster at execution Makefile code.


I bet this was inspired by the "Lisp in your language" post from last week, where somebody did it in JavaScript.

That got me to work on a Python version (using tuples, for maximum parentheses), but it got put on the back burner because my life took a turn for the busy lately.


A (very basic) version in Lua/LPEG I did a while ago:

https://gist.github.com/polymeris/857a7ae31db0d240ef3f


A part of me loves and a part of me hates the author.

10/10 would lithp again.


> There should be a lot of limitations. makelisp behaves very strangely when you pass a broken Lisp code.

I can't imagine why..


wonderful




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

Search: