> > The other question: is it possible to have two mutually refering deftype > definitions. >
Although recursive types makes sense on the JVM, it doesn't necessarily make sense on hosts without an explicit type system in which to resolve the mutual recursion; consider ClojureScript. You don't need recursive type definitions in order to have mutually recursive instances. You can simply indirect through mutation. For you particular case... > The closest I have got it: > (declare create-alice) > (declare create-brian) Yup, that's A-OK. You can also just write (declare create-alice create-brian). The tricky bit comes in when you actually need to refer to the types by name directly. Say, if you wanted to create mutually recursive deftypes with type hints (maybe for host interop reasons). In that case, you can indirect through interfaces/protocols: (defprotocol IFoo ...) (defprotocol IBar ...) (deftype Foo [^IBar bar] ...) (deftype Bar [^IFoo foo] ...) If you genuinely need mutually recursive types and can't indirect through protocols (or interfaces), then you probably have a particular JVM interop use case and should just write Java for that purpose. -- 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 --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.