Hi, Am 10.11.2010 um 17:37 schrieb Gary Poster:
> But that's exactly my point. Why should developers have to remember to use > rseq on a vector, as the first example? Why can't reverse simply be part of > a protocol, so that it gives O(1) when it can? Is there *any* practical > value to having reverse have O(n) performance on a vector? Clojure is > advertised as a practical language (I remember reading it early in JoC, for > instance), and I don't see it here. You got this backwards. There is nothing wrong with reverse being fast on vectors. But it's promise is only O(n). If you need fast reversal you have to use rseq. It makes your intention explicit and will protect you from someone passing in a seq or a list. rseq will bark at you, while reverse silently decays your applications performance. Another point is: last, butlast, reverse are all functions from the seq library. However there is a difference between seqs and datastructures. Currently there is a clear distinction between functions acting on datastructures and functions acting on seqs. And I think this is a good thing. One has to clearly understand both worlds: A vector is not a seq. A list happens to be its own seq. Not every seq is a list. Using the functions for datastructures clearly states in which world you are currently walking. As soon as you are in seq world you are in general bound to O(n). reverse being fast on vectors is at best an implementation detail. To be clear: I don't argue that reverse should be fast on vectors. Of course this would be a useful optimisation which basically comes for free. I argue that removing the data structure functions with their performance promises is a logical consequence of such an optimisation. Sincerely Meikel -- 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