Hi all,

Does IPersistentStack have defined stack semantics? I'm confused
because IPersistentStack defines peek and pop and (via
IPersistentCollection) conj. I had previously expected that peek and
pop would remove from the same end that conj adds to, as happens with
lists and vectors, in order to get last-in-first-out (LIFO) semantics.

I was therefore very surprised to discover that PersistentQueue
implements IPersistentStack, but with queue semantics instead! ie peek
and pop operate at the left, while conj operates at the right.

Why does PersistentQueue implement IPersistentStack? What does
IPersistentStack mean, if an implementor doesn't actually have to
define stack semantics? Is this by design or is it just an accident of
PersistentQueue implementing IPersistentList which in turn implements
IPersistentStack? Is it something which would just be too awkward to
work around?

I notice also that Agent's ActionQueue has an IPersistentStack q field
which holds a PersistentQueue, which indicates that someone at least
is comfortable with this relationship. Does this indicate that
IPersistentStack's semantics simply mean "a collection which can be
added to and removed from, in no particular order"? Is
IPersistentStack the best name to describe this?

Phil

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