My question is: why not have each conj! produce a new, lightweight
TransientVector instance pointing to the same shared data?

...

My guess is that the resulting ephemeral garbage would have only a
small effect on performance, retaining most of the advantage of
transients, but improving their safety. Would any of the Clojure
experts care to comment on whether this seems like a worthwhile
exercise?

(Not that I'd call myself a "Clojure expert", but...)

Transients are used all over the place, including in Clojure's own non- transient functions (such as merge).

If you're adding a new TransientVector instance on every call to conj!, you might as well just use conj.

Making transients slower -- even by a small amount -- strikes me as contrary to Rich's position. After all, transients are meant to be an optimization technique: write your code with persistent data structures, and if you find yourself banging on a chain of maps, say, add some !s, transients, and persistent!s, and you'll see a performance gain. They should never leave the scope of a particular function (or small group of functions), and by the time you're done writing you should make sure that you got it right.

Making them safer is analogous to asking for checks to be added to unchecked math operations.

You should *never* be shoving transients into vars, IMO.

That said, I agree with Stuart that a "debug" level of Clojure might be useful, making the "get it right" part easier. I don't favor a separate build, unless it's unavoidable: I think that Common Lisp's declarations are a reasonable starting point for discussion. Imagine if macros could see an environment with speed/space/safety attributes, and could generate appropriate code...

--
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

Reply via email to