         ] [ ] make define-inline
     ] [ 2drop ] if ;
 
-: define-slot-methods ( class slot name -- )
-    dup define-changer
-    dup define-setter
-    3dup define-reader
-    define-writer ;
+: define-slot-methods ( class slot-spec -- )
+    {
+        [ [ drop ] [ name>> ] bi* define-changer ]
+        [ [ drop ] [ name>> ] bi* define-setter ]
+        [ [ offset>> ] [ name>> ] [ type>> ] tri define-reader ]
+        [ [ offset>> ] [ name>> ] [ type>> ] tri define-writer ]
+    } 2cleave ;
 
 : define-accessors ( class specs -- )
-    [
-        dup slot-spec-offset swap slot-spec-name
-        define-slot-methods
-    ] with each ;
+    [ define-slot-methods ] with each ;
 
 : slot-named ( name specs -- spec/f )
     [ slot-spec-name = ] with find nip ;

! See http://factorcode.org/license.txt for BSD license.
USING: arrays kernel kernel.private math namespaces
sequences strings words effects generic generic.standard
classes slots.private combinators ;
IN: slots

TUPLE: slot-spec type name offset reader writer ;

C: <slot-spec> slot-spec

: define-typecheck ( class generic quot -- )
    [
        dup define-simple-generic
        create-method
    ] dip define ;

: define-slot-word ( class slot word quot -- )
    rot >fixnum prefix define-typecheck ;
