State of user extensible sequences

Discussion of Common Lisp
Post Reply
schoppenhauer
Posts: 99
Joined: Sat Jul 26, 2008 2:30 pm
Location: Germany
Contact:

State of user extensible sequences

Post by schoppenhauer » Wed Jun 29, 2011 7:43 pm

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

Code: Select all

(defclass my-seq (sequence) ())
I cannot use

Code: Select all

#'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/

nuntius
Posts: 538
Joined: Sat Aug 09, 2008 10:44 am
Location: Newton, MA

Re: State of user extensible sequences

Post by nuntius » Wed Jun 29, 2011 8:10 pm

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

astalla
Posts: 3
Joined: Fri Apr 22, 2011 2:03 pm

Re: State of user extensible sequences

Post by astalla » Thu Jun 30, 2011 2:26 pm

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

Code: Select all

(defclass my-seq (sequence) ())
I cannot use

Code: Select all

#'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:

Code: Select all

(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

schoppenhauer
Posts: 99
Joined: Sat Jul 26, 2008 2:30 pm
Location: Germany
Contact:

Re: State of user extensible sequences

Post by schoppenhauer » Fri Jul 01, 2011 12:29 am

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/

Post Reply