On Nov 10, 2010, at 11:16 AM, Meikel Brandmeyer wrote:

> Hi,
> 
> On 10 Nov., 17:09, Gary Poster <gary.pos...@gmail.com> wrote:
> 
>> I believe that the cost of having developers remember both rseq and reverse 
>> (why can't reverse just DTRT if it is given a vector?), last and peek 
>> (same), butlast and pop (same), and nth and get (same) is unnecessarily high.
> 
> Ehm. No.
> 
> rseq O(1), reverse O(n).
> peek O(1), last O(n).
> pop O(1), butlast O(n).
> get O(1), nth O(n).
> 
> (Where O(1) might sometimes mean O(log32 n))
> 
> The different functions are there under different names, because they
> have different performance promises.

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.

> Then peek is not equivalent to
> last. For lists it is equivalent to first.

OK, thank you.  As I said initially, the email could have been researched 
better, but the larger thought is still valid, with other reasonable examples.

Gary

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