jacobobryant / biff

A Clojure web framework for solo developers.
https://biffweb.com
MIT License
829 stars 40 forks source link

biff/pprint is variadic but its implementation takes only one argument. #214

Closed filipencopav closed 1 month ago

filipencopav commented 1 month ago

The function biff/pprint has the signature (pprint & args). However, its implementation only takes one argument.

(require ['com.biffweb :as 'biff])

(biff/pprint 1)
;; Prints `1`

(biff/pprint 1 2)
;; Unhandled clojure.lang.ArityException
;; Wrong number of args (2) passed to: com.biffweb.impl.util/pprint

Let's see what the definition of it is:

(defn pprint
  "Alias of clojure.pprint/pprint"
  [& args]
  (apply util/pprint args))

And util/pprint?

(defn pprint [x]
  (binding [*print-namespace-maps* false]
    (pp/pprint x))
  (flush))

So, util/pprint takes strictly one argument, however biff/pprint will try to invoke it with 0 or more than 1 arguments. Why does biff/pprint have this counter-intuitive signature?

jacobobryant commented 1 month ago

Thanks for the catch. I just pushed a commit to fix this: https://github.com/jacobobryant/biff/commit/edfd869b5866503d0ca2414874c1f37607c268ef