On Monday, July 16, 2018 at 3:21:02 PM UTC-5, Christian Seberino wrote: > > I'm impressed with Clojure syntax and I'm still a beginner. > > I noticed conj behaves differently for lists and vectors. I also noticed > cons does not return a vector for a vector input. >
It might be worth checking out this and other entries in the faq: https://clojure.org/guides/faq#conj > > Is there any downside to make 2 macros...prepend and append that behave > the same for lists and vectors, and also, > return same types as inputs? > The downside is that these operations would have different performance expectations for different data structures. That is the approach taken in many collection libraries (Java's is a good example) and Clojure intentionally breaks with that idea to instead say - these operations should give you a certain expectation, and we will only implement them when that expectation can be met. This is a difference in philosophy for sure. Having worked in both paradigms for extended periods of time, I have come to greatly appreciate the Clojure approach in allowing me to glance at, and reason about, a piece of code without needing to know which concrete data structure is actually at play. > If I'm not mistaken, I believe it is for performance reasons that these > are not already in the standard language? > For those that care about performance, it would be beholden on them to > pick the correct macro for their > specific data structure. > > Good idea? > It is highly unlikely we will ever add something like this to the stdlib. :) > > Thanks! > > Chris > > > -- 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 unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.