> Here's how I think you could do a mutable local: > (defn f [] > (def mut-local) > (binding [mut-local 0] > (set! mut-local 1) > mut-local)) > > (f) should yield 1 > > The flaw with this approach is that def actually creates a global > var. It remains unbound, but the fact that the function ends up > having a global effect is less than satisfying. > > Better ways?
Defining a global var just for local binding is not very clean, and unnecessary; (defn f [] (with-local-vars [myvar 1] (var-set myvar 2) (var-get myvar))) (f) -> 2 Check out the documentation for with-local-vars for an explanation. -- Jarkko --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---