next() should return either the remaining seq or null (think Clojure 
function next)
more() should return either the remaining seq or empty list (like Clojure 
function rest)

Inside Clojure, most seqs extend ASeq, which implements more() on top of 
the abstract next():

public ISeq more(){
    ISeq s = next();
    if(s == null)
        return PersistentList.EMPTY;
    return s;
}

equiv() is like equals() but equals() follows Java semantics and equiv() 
follows Clojure semantics. For your custom types, it's likely they mean the 
same thing.  

empty() returns a collection of the same type without any elements.

Not sure on mutually recurring deftypes - sounds tricky. It is entirely 
possible this has come up on clojure or clojure-dev mailing lists in the 
past so I would start by searching there.

Alex


On Friday, February 7, 2014 6:00:41 AM UTC-6, Phillip Lord wrote:
>
>
>
> I've been playing with some code recently. I was wondering how hard 
> would it be to implement, for example ISeq in clojure. The plan was to 
> use deftype and a few bits of other code. 
>
> The ISeq interface looks like this: 
>
> public interface ISeq extends IPersistentCollection { 
>
> Object first(); 
>
> ISeq next(); 
>
> ISeq more(); 
>
> ISeq cons(Object o); 
>
> } 
>
>
> And here is the problem -- it looks exactly like this! There is no 
> documentation. While first and cons are guessable, I am still not sure 
> of the difference between next and more. Likewise, IPersistentCollection 
> has "equiv" and "empty" -- guessable again. 
>
> The other question: is it possible to have two mutually refering deftype 
> definitions. 
>
> So 
>
> (deftype Alice () 
>    (other [] (Brian.))) 
>
> (deftype Brian () 
>    (other [] (Alice.))) 
>
> The closest I have got it: 
>
> (declare create-alice) 
> (declare create-brian) 
>
> (deftype Alice () 
>     (other [] (create-brian))) 
> (deftype Brian () 
>     (other [] (create-alice))) 
>
> The last could be 
>
> (deftype Brian () 
>     (other [] (Alice.))) 
>
> but the symmetry seemed good. 
>

-- 
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/groups/opt_out.

Reply via email to