1. 12
  1.  

  2. 11

    Slightly (greatly?) less provocative title: “S-Expressions are not ASTs”.

    With respect to specific points, Clojure and Racket have good solutions for many of these things.

    RE #1: Annotations can be handled generically. Take a look at Clojure’s metadata facilities: https://clojure.org/reference/metadata

    RE #2 cons: Clojure’s data structures are abstract (defined in terms of interfaces) and extensible (there is a tagged-literal type). Check out EDN: https://github.com/edn-format/edn - or more general these resources: https://clojure.org/reference/data_structures and https://clojure.org/reference/reader

    RE #2 compiler internals: The ClojureScript compiler uses an AST made out of recursive maps. Works quite nicely. “tools.analyzer” does this too. Check out the readme: https://github.com/clojure/tools.analyzer

    RE #2 & #3 special backquote: Racket does exactly this with “syntax objects”. Racket’s syntax objects only capture lexical origin and scope nesting information, but you can go even further with this. For example, MetaOCaml, Terra, or other staging systems can capture full lexical closures attached to first-class, user-level syntax fragments. See http://okmij.org/ftp/ML/MetaOCaml.html and http://terralang.org

    1. 4

      Symbols are not the right representation of identifiers. … A symbol can be a convenient abbreviation, but in general an identifier needs to be a combination of a name and a lexical context.

      This was a major problem (at least for me) in REBOL, which allowed you to manipulate words as first-class objects, construct function bodies from blocks (lists) and then execute them and so on. It let you do some really neat macro stuff (though it wasn’t called that), but each word had a hidden pointer back to its defining context such that when a word was encountered it could be very difficult to intuit what value it would produce when evaluated.

      (It might have been that I was trying to be too clever with the power that REBOL afforded me…)

      1. 3

        It hasn’t been until very recently that people have been able to even fathom the idea that you could have a Lisp that isn’t based on sexprs. It seems like once people learn Lisp they accept sexprs as necessary to the point of not being able to imagine anything else. So, I’m really grateful for all the time Moon has spent dreaming/studying this idea.

        1. 2

          Not so sure about this. There’s been gadzillion attempts at lisp with infix syntax. It’s a common early idea of a newcomer to the language that never sticks as you progress.

          There’s even been a real lisp (Dylan) with mature implementations and corporate support which tried to do away with sexprs. Didn’t fare well.

          1. 2

            It’s a common early idea of a newcomer to the language that never sticks as you progress.

            Maybe I don’t want Lisp in so much as as much of Lisp’s values without the sexprs. I concede I may lose something in the process. I’d also argue Ruby was a successful take on this idea in the OO realm even if it lacks a lot of the power of Lisp.

            There’s even been a real lisp (Dylan) with mature implementations and corporate support which tried to do away with sexprs. Didn’t fare well.

            I’m not comfortable disregarding ideas just because they didn’t experience success with the mainstream. I find Dylan beautiful and forward-thinking. Based on what I’ve read of Dylan, I don’t believe a deficiency of the language caused it to be passed over; but rather the circumstances of the institutions and time period it was created in.

            1. 1

              Same could be said of LISP itself versus mainstream languages or JVM LISP versus native LISP. The other factors of language adoption probably dropped those other attempts like they did most of the LISP’s with regular syntax. Hardly any made it. Those that did would also have strong cultural pressure on keeping syntax style that was popular in that niche.

              Still a chance that a Python or Clojure-like project with most things going for it could succeed with non-traditional syntax mixed with a capable LISP implementation.

            2. 1

              The Ancient Lisper in me (yes, I have a treasured copy of McCarthy’s Lisp manual) gets the giggles when I note TFA is hosted on cddddr.org