On Nov 12, 1:10 pm, Rich Hickey <richhic...@gmail.com> wrote: > An early version of the code for a few important new language > features, datatypes[1] and protocols[2] is now available in the 'new' > branch[3]. Note also that the build system[4] has builds of the new > branch, and that the new branch works with current contrib. > > If you have the time and inclination, please try them out. Feedback is > particularly welcome as they are being refined. > > Thanks, > > Rich
I've had very good experiences so far - I really like the modeling aspects of this. Two comments. First is a bug. Using newest commit of new: 75cd05080f7260c54007d7728fb280ae53b56f63 Clojure 1.1.0-alpha-SNAPSHOT user=> (deftype Foo [x]) #'user/Foo user=> (defprotocol P (fun [x])) P user=> (extend ::Foo P {:fun (fn [x] x)}) nil user=> (fun (Foo 42)) #:Foo{:x 42} user=> (def f1 (Foo 42)) #'user/f1 user=> f1 #:Foo{:x 42} user=> (def f2 (fun f1)) java.lang.IllegalAccessError (NO_SOURCE_FILE:7) user=> The error occurs if I try to bind the result of a protocol function to a var. Second is a feature request: Map-based initializers and Default values for deftype. Example: user=> (deftype TransitionPolicy [fail-count timeout]) #'user/TransitionPolicy user=> (def p (TransitionPolicy {:fail-count 5 :timeout 5000})) ;; I'd like 'user/p user=> p #:TransitionPolicy{:fail-count 5, :timeout 5000} user=> Now defaults: user=> (deftype TransitionPolicy [fail-count :def 5 timeout :def 5000]) ;;I'd like #'user/TransitionPolicy user=> (TransitionPolicy :fail-count 5) #:TransitionPolicy{:fail-count {:fail-count 10}, :timeout 5000} user=> (TransitionPolicy) #:TransitionPolicy{:fail-count 5, :timeout 5000} I know I can easily construct functions that realize these maps and default initializers, but it would be nice to have Out-of-the-box if it doesn't complicate the design. Cheers, /Karl -- 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