[Openmcl-devel] Applying sequence functions to a new type
Andrew P. Lentvorski, Jr.
bsder at mail.allcaps.org
Mon Feb 28 23:14:37 PST 2005
This is probably a really stupid question, but how do I define the
sequence functions so that they apply to a new class?
For example, let's say I want a stupid class that always has two
elements a and b. I would like to be able to access a and b as thought
they were elements 0 and 1 of a sequence.
Welcome to OpenMCL Version (Beta: Darwin) 0.14.2-040925!
? (defclass Vec2 ()
((a :accessor a
:initarg :a)
(b :accessor b
:initarg :b)))
#<STANDARD-CLASS VEC2>
? (setq v2 (make-instance 'Vec2 :a 7 :b 11))
#<VEC2 #x644EAB6>
? (elt v2 0)
> Error in process listener(1): value #<VEC2 #x644EAB6> is not of the
expected type SEQUENCE.
> While executing: CCL::SEQUENCE-TYPE
> Type :POP to abort.
Type :? for other options.
1 > ^D
? ;; Okay, let's try a different tack
(defclass Vec2 (sequence)
((a :accessor a
:initarg :a)
(b :accessor b
:initarg :b)))
> Error in process listener(1): The class #<BUILT-IN-CLASS SEQUENCE>
was specified as a
> super-class of the class
#<STANDARD-CLASS VEC2>;
> but the meta-classes #<STANDARD-CLASS
BUILT-IN-CLASS> and
> #<STANDARD-CLASS STANDARD-CLASS> are
incompatible.
> While executing: #<CCL::STANDARD-KERNEL-METHOD SHARED-INITIALIZE
:AFTER (CCL::SLOTS-CLASS T)>
> Type :POP to abort.
Type :? for other options.
1 >
? ;; Okay, that sure didn't work
So how do I define a function elt or redefine Vec2 such that elt can be
written to work with it?
Thanks,
-a
More information about the Openmcl-devel
mailing list