Skip to content

Comment on Adding syntax to the CPython interpreter

Comments

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))

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
AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.