I'm trying to think of scenarios where circular references would be a problem in Clojure. When does memory actually have to be allocated? Inside a let block, most often. When lexically scoped variables are passed to a function, their reference count increases as they are bound to its parameters, but they're also immutable. One thing about a language like Clojure (as compared to C++) is that lexical scopes themselves can be first-class objects (at least from the implementation's point of view). A let block could manage the memory it needs for its own variables, and passing variables to a function could be some kind of transaction between a let block and a lambda block. An object would have only one reference from its initial let block, and all other references would be from lambda blocks, which would always call some cleanup method before the let block does. Obviously things get more complicated when concurrency features like ref and atoms get involved, but, as I understand it, there must be a transaction object in memory for a Clojure variable to be nonconstant, and that object could notify a let block which allocates memory for a variable when the memory can be deallocated. It sounds like the issues other writers have raised (and thanks alot for the feedback) are that concurrency in C++ would be slower than concurrency in normal Java Clojure, but even if this is true, I am interested in a C++ version of Clojure not primary for speed considerations, but for the flexibility of not needing a JVM to run Clojure code. BTW, does anyone know what kind of GC algorithms (reference counting or thread- based or what) are used by other Lisps? I know Perl used to use a reference-counting-based system, but Perl6 now says "reference- counting is dead". Setting aside concurrency features, I'm not sure how Clojure memory management would differ substantially from other Lisps; Clojure let blocks used seq'able objects to contain their variables being declared, but I don't see how that would affect memory management for them.
-- 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 Note that posts from new members are moderated - please be patient with your first post. 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