[Openmcl-devel] Applying sequence functions to a new type
dankna at accela.net
Wed Mar 2 07:13:58 EST 2005
>> People may be left with the impression that Common lisp really should
>> have an extensible abstract protocol for defining SEQUENCE-like
>> on SEQUENCE-like objects. There is not (and never has been) anything
>> stopping anyone from developing such a library, aside from the fact
>> designing something general and usable is hard.
> Well, it also winds up not being a basic part of Common Lisp. It
> winds up being like the Standard Template Library for C++. That only
> took *how* many years before it's existence could actually be assumed?
> Fortunately, Common Lisp does not have the same level of baseline
> incompatibility problems that the C++ compilers had.
It could actually be pretty small, I think. Difficult to write,
mostly because it
isn't clear what the semantics should be, but not large. So this
library could easily be included with other projects, as necessary.
The easiest way would probably be something like:
(:shadow "CAR" "CDR" "NTH" "AREF" .....))
(defgeneric nth (n seq)
(:method ((n (integer 0)) (seq t))
(cl:nth n seq)))
Then packages wanting these semantics would just use the "CL-SEQUENCE"
package instead of "CL", and everything else would be unaffected.
Mind you, I haven't even thought about whether it would be a good
just pointing out that CL does make it pretty easy to implement this
language extension, since that is after all a lot of what Lisp is
about. Being a
formal part of the language is only relevant if optimization is needed
it usable - and even for that, there are compiler macros.
-- Dan Knapp
More information about the Openmcl-devel