Implementing ISeq

215 views
Skip to first unread message

Garth Sheldon-Coulson

unread,
Jul 7, 2009, 5:31:58 PM7/7/09
to clo...@googlegroups.com
Hello Clojurians---

I'm about to begin writing a Clojure wrapper for a Java data structure that's amenable to seq-ability.

1) I'd like to implement the ISeq interface. Could someone point me to some up-to-date documentation on what I need to implement? Sorry if this is covered somewhere obvious... I couldn't find it.

Stu's book and the web site seem to indicate that "first," "cons," and "rest" are the important things (are they all?). Yet I see discussions online about, e.g., "next," and looking inside clojure.lang.ISeq I see cons, first, more, and next. Am I right in assuming that Clojure constructs (rest coll) out of some combination of these? Could someone shed some light on this?

2) Can one enhance the performance of the seq library by implementing more than the basics (i.e. more than [first cons rest] or [first cons more next])? Or is the whole idea that the entire edifice is built on just the basics?

3) How stable is the interface at this point?

Thanks.
Garth

Rich Hickey

unread,
Jul 7, 2009, 6:21:53 PM7/7/09
to Clojure
You should have a look at clojure.lang.StringSeq and
clojure.lang.IteratorSeq. Deriving from ASeq as they do is the way to
go. The interface is stable, and no, there are no other optimizations
needed.

Rich

Garth Sheldon-Coulson

unread,
Jul 7, 2009, 6:49:06 PM7/7/09
to clo...@googlegroups.com
Thanks Rich, I'll take a look.

By the way, Clojure is a beautiful and enriching thing. Keep up the great work.
Reply all
Reply to author
Forward
0 new messages