anchor.diff:  (defun length (#1=charseq)
     (declare (#1# #1#))
     (- (end #1#) (beg #1#)))
  +
  +(defmacro with-check ((test-form datum &rest arguments) &body body &environment env)
  +  ;; TODO: ccl
  +  (if #+SBCL (eql 0 (cdr (assoc 'common-lisp:safety (sb-c::lexenv-policy env))))
  +      #-SBCL nil
  +      `(locally ,@body)
  +    `(progn 
  +       (unless ,test-form
  +         (error ,datum ,@arguments))
  +       (locally
  +	,@body))))
       
   (defun ref (#1=charseq index)
  -  (declare (#1# #1#)
  -       (index index))
  +  (declare (#1# #1#) (index index))
     (char (str #1#) (+ (beg #1#) index)))
  +
  +(define-compiler-macro ref (charseq index)
  +  (let ((cs (gensym))
  +	(i  (gensym)))
  +    `(let ((,cs ,charseq)
  +           (,i  ,index))
  +       (declare (charseq:charseq ,cs) (charseq:index ,i))
  +       (with-check ((common-lisp:< ,i (charseq:length ,cs))
  +                    'invalid-index-error :length (charseq:length ,cs) :index ,i)
  +         (char (str ,cs) (+ (beg ,cs) ,i))))))
   
   (defmacro each ((char charseq &optional result) &body body)
     (let ((tmp (gensym))
  
positive.code:         (,start  (beg ,tmp))
          (,end    (end ,tmp)))
         (declare (ignorable ,string ,start ,end))
         ,@body)))
negative.code:          (with-slots (length start end) condition
             (format stream "The bounding indices ~A and ~A are bad for a string of length ~A."
                 start end length)))))
  
  (define-condition invalid-index-error (error)
    ((index  :initarg :index)
     (length :initarg :length))
    (:report (lambda (condition stream)
               (with-slots (length index) condition
                 (format stream "Index ~A out of bounds of (~A ~A), should be nonnegative and <~A."
                         index 'charseq length length)))))
   
  (defstruct (charseq (:conc-name ""))
    (str "" :type (simple-array character) :read-only t)
  