I would like to be able to encapsulate local state in a closure.
Specifically, I would like a function that returns an incrementing
integer, thus:
(test_func)
1
(test_func)
2
What is the best way to go about this?  With local bindings is failing
and I can't figure just why...

(def test_closure
           (with-local-vars [one 1]
             (fn [] (var-get one))))
#'user/test_closure
user> (test_closure)
; Evaluation aborted.
The var is null when I call the closure.

Thanks,
Chris
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to