Lisp moving Forth moving Lisp

(letoverlambda.com)

31 points | by fallat 2 days ago

1 comments

  • Vohlenzer 1 hour ago
    I finished Let Over Lambda recently. I'm not an experienced lisp programmer but it's strangely readable if you allow yourself to not understand every little detail of the Common Lisp code. For example I hadn't read On Lisp. I had read The Little Schemer.

    It's a wonderful tour of advanced macro concepts. With several of the macros presented I found myself saying "well that's just x language feature in y" but that's missing the point. The point is that Common Lisp allows you to implement your own language features, with macros of course!

    This chapter is a wonderful climax to the whole book. Lisp moving Forth moving Lisp reminded me of the intertwined nature of DNA, RNA and proteins in Biology.

    There's great humour throughout the book, I especially enjoyed the little sideways jabs at Scheme programmers!

    • peheje 1 hour ago
      What are some genuinely useful things macros can do?
      • Vohlenzer 16 minutes ago
        One of the cleanest examples in the book is the CL-PPCRE library for regular expressions.

        Without macros, regular expressions are strings at compile time and then at runtime objects are created based on the strings to evaluate them.

        With macros, regular expressions are expanded at compile time into Common Lisp code that implements the evaluation.

        There's a similar idea with an ORM library.

        Without macros, the object-relational mapping is defined at compile time and any dynamic SQL is generated at run time.

        With macros, the object-relational mapping is used at compile time to expand the query macros into Common Lisp code that includes the actual SQL.

        Then also remember that the compiler is available at runtime in a lisp, so the distinction only matters when comparing it to non-lisps.

      • Akronymus 39 minutes ago
        AFAICT, actually manipulating the AST, which then in turn allows you to implement your own language features, inserting additional debugging info, memoizing a function by just wrapping it in a macro, or optimizations based on domain knowledge.
      • arvyy 27 minutes ago
        all the things, if macro system is sufficiently sophisticated (ie., hygienic with ability to attach metadata to syntax object). Racket is one of languages with such system, and they implemented static typing using them.
      • db48x 49 minutes ago
        They can define new syntax and special forms.