Live data from Hacker News

Mal – Make a Lisp

github.com

11–20 of 41 posts

Re: Mal – Make a Lisp

#11
post #2

Interesting languages that aren't on the list of implementations: APL/J/Kx Verilog Fortran LISP 1.5

Also COBOL and VHDL. I don't know how a hardware description language could implement a Lisp variant btw.

Re: Mal – Make a Lisp

#12
post #5
post #4

I attempted this a few years back, didn't get far before I got hung up on the regular expression(s) required for parsing. Silly to get stopped there, but there was just enough friction between the specified expression, the language I was using (Erlang), and my understanding of the subtleties that I punted. I think with Regex101 in my back pocket I'll give it another try. https://regex101.com

Regex to parse lisp expressions?

The regex is used as a tokenizer, the outputs of which are then fed into the reader module.

Re: Mal – Make a Lisp

#13
I went through MAL last year and had a blast! It's an excellent project to help you get a feel for Lisps and tiny languages, and I think is what finally got me over my "eww parentheses" feeling. After finishing MAL, I modified it to implement John Shutt Kernel-style f-exprs to really up the power-to-weight ratio, and had a blast doing it. MAL makes a great basis for experimenting with additional language features, highly recommended!

Re: Mal – Make a Lisp

#14
post #9

Earlier quoted context omitted.

Regexes are at least useful for parsing numbers and symbols. But yeah, that shouldn't be where you get stuck.

[\s,] (~@|[\[\]{}()'`~^@]|"(?:\\.|[^\\"]) "?|;. |[^\s\[\]{}('"`,;)] ) Step 0, so I didn't get very far. https://github.com/kanaka/mal/blob/master/process/guide.md#s...

Whoa that regex is a monster. Try starting with simpler pieces and see if you get further this time around. Good luck! https://gist.github.com/cellularmitosis/75dc4aefe88438c14e94...

Re: Mal – Make a Lisp

#15
post #11
post #2

Interesting languages that aren't on the list of implementations: APL/J/Kx Verilog Fortran LISP 1.5

Also COBOL and VHDL. I don't know how a hardware description language could implement a Lisp variant btw.

There is a Verilog implementation of the MIT Lisp Machine.

Re: Mal – Make a Lisp

#16

I went through MAL last year and had a blast! It's an excellent project to help you get a feel for Lisps and tiny languages, and I think is what finally got me over my "eww parentheses" feeling. After finishing MAL, I modified it to implement John Shutt Kernel-style f-exprs to really up the power-to-weight ratio, and had a blast doing it. MAL makes a great basis for experimenting with additional language features, hi…

I liked MAL similar to Linux from scratch (LFS).

Re: Mal – Make a Lisp

#17
post #11
post #2

Interesting languages that aren't on the list of implementations: APL/J/Kx Verilog Fortran LISP 1.5

Also COBOL and VHDL. I don't know how a hardware description language could implement a Lisp variant btw.

They actually do include a VHDL implementation! COBOL would be cool though.

Re: Mal – Make a Lisp

#18
post #4

I attempted this a few years back, didn't get far before I got hung up on the regular expression(s) required for parsing. Silly to get stopped there, but there was just enough friction between the specified expression, the language I was using (Erlang), and my understanding of the subtleties that I punted. I think with Regex101 in my back pocket I'll give it another try. https://regex101.com

In C#, I ended up with

   static public List Tokenizer(string source)
   {
      // Initialise the token list.
      List tokens = new List();

      // Define a regex pattern whose groups match the MAL syntax.
      string pattern = @"[\s ,]*(~@|[\[\]{}()'`~@]|""(?:[\\].|[^\\""])*""|;.*|[^\s \[\]{}()'""`~@,;]*)";
      //                 empty  ~@ | specials     |   double quotes      |;  | non-specials

      // Break the input string into its constituent tokens.
      string[] result = Regex.Split(source, pattern);
This took a while to understand and get going but it really improved my understanding of regex.

Re: Mal – Make a Lisp

#19
I did this a while back. I documented my experience in several blog posts, the last of which is [0]. These describe the process, the gotchas and how I got round them. I was working on C# on a Windows box so the result isn't quite the same as the vanilla MAL.

I was massively pleased when I got MAL to self-host.

[0] https://www.non-kinetic-effects.co.uk/blog/2019/04/28/MAL-5

Re: Mal – Make a Lisp

#20
I went through this a while ago (in Prolog). It was interesting, but with a lot of room for improvement. My criticisms as I remember them:

- Error messages about output being different from the expected use some sort of very explicit printing mode with lots of quotes and escaping. A message saying that one got "\\\'\\\'" where "\'\\\\'" was expected is needlessly hard to parse when the actual difference is \'\' vs. '\\' (or whatever).

- Many parts are marked optional, but the test script complains if you don't implement them, and later sections assume that they are implemented, so you have to treat them as compulsory anyway.

- Some things regarding environment updates were contradictory or at least not explained properly at first, with some very relevant information only coming later. I don't remember the specifics, but the problem was roughly that I set up my data structures thinking that everything could be implemented in a pure way, but at some point it became clear that you either need some other data structure or must use destructive modifications.

Post reply on HN