I've wrapped my random uuid generator up in a little library at: https://github.com/franks42/cljs-uuid-utils
--- cljs-uuid-utils ClojureScript micro-library with an implementation of a type 4, random UUID generator compatible with RFC-4122 and cljs.core/UUID (make-random-uuid), a uuid-string conformance validating predicate (valid-uuid?), and a UUID factory from uuid-string with conformance validation (make-uuid-from). --- As mentioned before, clojure on the jvm can leverage the ubiquitous "java.util.UUID/randomUUID", while there is no generally available random uuid generator in the javascript world. Although this micro-lib addresses that issue somewhat, I believe that we should have a random-uuid generator as part of the batteries-included cljs-distro. Another issue that I came across is the fact that the java.util.UUID/fromString does do a conformance check of the presented uuid-string, and throws an exception if it does not pass. ClojureScript's reader yields a cljs.core/UUID instance for uuid-literals, but doesn't check for any conformance and essentially accepts any string. This could lead to interesting, surprising bugs during cljs-clj interop. Please let me know if you use this little library, and any suggestions/comments for improvement are always welcome. Enjoy, FrankS. On Nov 29, 2012, at 10:20 AM, David Nolen <dnolen.li...@gmail.com> wrote: > Also note that testing with the Rhino REPL is not informative about > performance in anyway - you absolutely need to test your code against the > modern JS engines - V8, JavaScriptCore, or SpiderMonkey (with JIT turned on). > For code like this they are often 100X faster if not far greater than that. > > > On Thu, Nov 29, 2012 at 1:07 PM, Frank Siebenlist > <frank.siebenl...@gmail.com> wrote: > Thanks for the feedback! > > Defining the two helper functions outside of the function-scope doesn't seem > to have any effect on the performance numbers. > > …but I have to confess that all testing was done at the repl without any > optimization so far… > > -FS. > > > > On Nov 29, 2012, at 8:36 AM, David Nolen <dnolen.li...@gmail.com> wrote: > > > Oh though before you lift them out by hand - I would double check that > > :simple optimizations doesn't already do this for you :) > > > > > > On Thu, Nov 29, 2012 at 1:25 AM, Frank Siebenlist > > <frank.siebenl...@gmail.com> wrote: > > I need UUIDs in my CLJS code… > > > > cljs.core does include a UUID type, but no generator. > > > > I found a couple of efforts and example code at > > https://github.com/davesann/cljs-uuid and > > http://catamorphic.wordpress.com/2012/03/02/generating-a-random-uuid-in-clojurescript, > > but they didn't work with cljs.core/UUID or were too slow. > > > > There are many javascript versions out there, but that would require > > another external js-lib. > > (really surpising that I couldn't find a UUID generator in closure-lib…) > > > > Please take a look at my UUID-playground at > > "https://gist.github.com/4159427", > > which includes a few implementations with some rudimentary timing results. > > > > Appreciate any comments or suggestions, or maybe a pointer to a faster, > > cleaner implementation... > > > > Thanks, FrankS. > > > > PS. I would think that the cljs-community would love to have a UUIDv4 > > generator as part of the clojurescript distro... > > > > > > -- > > 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 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 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 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 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