Skip to content

Instantly share code, notes, and snippets.

@oranenj
Created June 30, 2009 19:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oranenj/138339 to your computer and use it in GitHub Desktop.
Save oranenj/138339 to your computer and use it in GitHub Desktop.
(defn make-panel []
(let [cnt (atom 0)
the-panel (proxy [JPanel] ...)
accessor (fn [] @cnt)]
{:panel the-panel
:accessor accessor})) ;return a map containing the panel and its accessors
(let [panel-map (make-panel)]
(.someJPanelMethod (:panel panel-map))
((:accessor panel-map))) ; access counter through closure
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment