←back to thread

160 points leontrolski | 1 comments | | HN request time: 0.25s | source
Show context
dig1 ◴[] No.41887606[source]
This is where Lisp-like languages excel with macros. An example in Clojure:

    (defmacro do* [body expr cond]
     `(~expr ~cond
       ~body))

     (do* (println "hello") if true)
     (do* (println "hello") when-not (> 1 2))
replies(1): >>41888240 #
1. BoingBoomTschak ◴[] No.41888240[source]
Yeah, this is the kind of material that shows that any attempt to prevent/hamper meta-programming or punt it to preprocessors is at best misguided. It also feeds the smug Lisp weenie within me.

  Above all the wonders of Lisp's pantheon stand its metalinguistic tools; by their grace have
  Lisp's acolytes been liberated from the rigid asceticism of lesser faiths. Thanks to Macro and
  kin, the jolly, complacent Lisp hacker can gaze through a fragrant cloud of setfs and defstructs
  at the emaciated unfortunates below, scraping out their meager code in inflexible notation, and
  sneer superciliously. It's a good feeling.

  -- iterate manual, A.1 Introduction
do..while is also the example used here https://www.tcl-lang.org/man/tcl9.0/TclCmd/uplevel.html