I\'m learning how to extend Java classes in Clojure, but I don\'t see a way declare new member variables; I only see a way for methods.
(ns test.aclass
(:g
The body of a proxy is a lexical closure, so you can just close around whatever variables you need. If, God forbid, you need to mutate them, then close around an atom:
(defn lying-list [init-size]
(let [the-size (atom init-size)]
(proxy [java.util.ArrayList] []
(size [] @the-size)
(remove [idx] (reset! the-size idx), true))))
There's really no need for actual Java fields here.