Hi all,
I've defined a custom vector type and implemented various clj/cljs
protocols, but now ended up hitting my head against some weird behaviour
with conj (or rather cons, internally). The type
defines a 2-element vector-like construct and my cons
implementation would simply return a standard
Not a direct answer but you might want to look at
https://github.com/ztellman/clj-tuple/blob/master/src/clj_tuple.clj
On Wed, Sep 3, 2014 at 1:13 PM, Karsten Schmidt i...@toxi.co.uk wrote:
Hi all,
I've defined a custom vector type and implemented various clj/cljs
protocols, but now ended
Hmm... since ISeq extends IPersistentCollection and overrides the
latter's return type, cons must return an ISeq. So do I understand it
correctly, that one *can't* have a deftype which returns itself as
Seqable *and* has vector-style conj behavior (i.e. append at tail
position)?
K.
On 3
Thanks, Kovas! I looked at it a few months ago (and now just forked
it), but Zach also seems to have created a separate deftype just to
support this conj-ing business (and that alone is 180 LOC...) That all
seems to be a huge effort though and am wondering about simpler
alternatives and/or some
One nuance to consider re: self-sequable datastructures is that on
eval clojure will assume the first element is invocable, see
https://github.com/ztellman/clj-tuple/issues/5
On Wed, Sep 3, 2014 at 1:51 PM, Karsten Schmidt i...@toxi.co.uk wrote:
Thanks, Kovas! I looked at it a few months ago
Your implementation of cons in your deftype is probably being associated to
the ISeq type, not IPersistentCollection.
user= (deftype Foo [a b]
#_= clojure.lang.IPersistentCollection
#_= (cons [_ c] [a b c]))
user.Foo
user= (conj (Foo. 1 2) 3)
[1 2 3]
I think Vector supports ISeq