Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I bet CL allows generalizing nth and cdr. My point is still that the list structure in Lisp is very baked into the language.


Common Lisp has a standard abstract data structure called 'sequence' and generic operations for it. Sequences are either vectors or lists. Vectors are bit vectors, strings, general vectors, ... Sequence operations are then supported for all subtypes of sequences.

http://www.lispworks.com/documentation/HyperSpec/Body/c_sequ...

There are some problems with this design. The main motivations for it were:

* basic operations in Lisp are type specific, one wanted to have some generic operations and a generic sequence abstraction over lists and vectors

* the low-level data structures like conses, arrays, tables are not object-oriented and generic

* generic operations in a dynamically typed language are slower, since there is always a runtime dispatch necessary

* to remove runtime dispatch one can use type declarations (which are optional in Common Lisp) or a JIT compiler (which is not used in most implementations, they do AOT compilation)

* the language at the type of this design had no agreed OOP extension - CLOS came some years later -> sequences are non-extensible and don't support adding new sequence types

The design of this was later improved in languages like Dylan: see the Collections of Dylan

http://lispm.de/docs/prefix-dylan/book.annotated/ch12.html

Recently some CL implementations experiment with extensible sequences.

http://www.doc.gold.ac.uk/~mas01cr/papers/ilc2007/sequences-...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: