This is a read-only archive of lispforum.com. The forum was locked to new users and posts and is preserved here as static HTML from a database snapshot taken on 2019-09-07.

State of user extensible sequences

4 posts · 1742 views

As it would come handy in what I am currently programming, I was wondering whether "User-extensible sequences in common Lisp" described in http://citeseerx.ist.psu.edu/viewdoc/do ... 1&type=pdf or something similar has already made its way into some common lisp implementation. Does anybody know this?

Edit:
Ok, just after I posted this I found that SBCL seems to have this extension. But something is not working. When defining
(defclass my-seq (sequence) ())
I cannot use
#'make-instance
There is no applicable method for the generic function #<STANDARD-GENERIC-FUNCTION INITIALIZE-INSTANCE (5)>. Why is that? Why do I have to write my own initialize-instance? Usually, this is done automatically.
Sorry for my bad english.
Visit my blog http://blog.uxul.de/

Re: State of user extensible sequences

Unfortunately, I don't believe this has seen widespread adoption. Try SBCL. There's also a port to ABCL.

I don't have first-hand experience with this protocol. Need to change that...

Re: State of user extensible sequences

schoppenhauer wrote:Ok, just after I posted this I found that SBCL seems to have this extension.
In fact Christophe Rhodes, the author of the extensible sequences paper, is an SBCL developer and quite famous Lisper.
schoppenhauer wrote:But something is not working. When defining
(defclass my-seq (sequence) ())
I cannot use
#'make-instance
There is no applicable method for the generic function #<STANDARD-GENERIC-FUNCTION INITIALIZE-INSTANCE (5)>. Why is that? Why do I have to write my own initialize-instance? Usually, this is done automatically.
You have to explicitly specify standard-object as a superclass, since it's not a superclass of sequence and the implementation is not allowed to change that. So:
(defclass my-seq (sequence standard-object) ())
I ported the SBCL implementation of extensible sequences to ABCL. If you're familiar with the Java Collections API, you might want to have a look at how I integrated it with CL sequences in ABCL [1]. Not that it's particularly clever or anything, it's pretty naive, but nevertheless it's an example of the usage of the extensible sequences protocol.

[1] http://trac.common-lisp.net/armedbear/b ... tions.lisp

Re: State of user extensible sequences

Thank you. Yes, that works. I wonder how efficient this is, I think I would not have implemented this extension with the object system, but rather with callbacks, for reasons of efficiency, but who cares.

I wonder why other implementations do not adapt this. Having some mechanism of optimizing what #'elt actually does should be necessary anyway, as vectors, non-adjustable arrays and adjustable arrays, and lists should have completely different methods of accessing, so this should be some work, but not too much (I would expect that gray streams had been more work).
Sorry for my bad english.
Visit my blog http://blog.uxul.de/