News for hackers. Stuff that matters.
Re:Homoiconicity Revisited by fiddlerwoaroof on Friday June 05, 2020 @05:56AM (#23426758)
The issue I’ve had with things like that is that I have to learn a whole new API for manipulating syntax: while there are definite advantages to this, representing code as everyday types that very generic functions can operate on has the advantage of making metaprogramming look like normal code. e.g. if I’m doing try...finally... stuff alot, I can right a macro that transforms:

(with-db [conn (connect ...)] ...)

To:

(let [db (connect ...)] (try ... (finally (close db)))

Just like:

    (defmacro with-db [[sym expr] & body]
      `(let [~sym ~expr]
        (try ~@body
          (finally (close ~sym)))))
The backtick/tilde notation isn’t macro-specific: it’s a generic way to template readable datastructures that I can use anywhere, so when I see it in a macro, it isn’t some strange API to learn, it’s just a handy way to build up the datatypes I use all the time.

There are no comments on this comment yet.