State of user extensible sequences

Discussion of Common Lisp

State of user extensible sequences

Postby 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/download?doi=10.1.1.65.1604&rep=rep1&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/
schoppenhauer
 
Posts: 99
Joined: Sat Jul 26, 2008 2:30 pm
Location: Germany

Re: State of user extensible sequences

Postby 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...
User avatar
nuntius
 
Posts: 500
Joined: Sat Aug 09, 2008 10:44 am
Location: Burlington, MA

Re: State of user extensible sequences

Postby 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/browser/trunk/abcl/src/org/armedbear/lisp/java-collections.lisp
astalla
 
Posts: 3
Joined: Fri Apr 22, 2011 2:03 pm

Re: State of user extensible sequences

Postby 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/
schoppenhauer
 
Posts: 99
Joined: Sat Jul 26, 2008 2:30 pm
Location: Germany


Return to Common Lisp

Who is online

Users browsing this forum: Bing [Bot], Yahoo [Bot] and 5 guests