anchor.diff:  ;;======================
   
   
  +;;hacky way to accomodate both forms...
  +;;we know we're in clojure if the args are vector
  +(defmacro deftype (&rest args)
  +   (if (vector? (nth 1 args))
  +       `(clojure-deftype ,@args)
  +       `(common-lisp::deftype ,@args)))
  +
  +;;reify is interesting.
  +;;we generate an instance of an anonymous class,
  +;;ala deftype, with protocol implementations.
  +;;TODO: look at the consequences of having bunches of
  +;;anonymous classes laying around, say evaluating
  +;;reify several times...Should we garbage collect this?
  +;;Or does that cut into dynamicity?
  +
  +(defmacro reify (&rest implementations)
  +  (let [classname (gentemp "REIFY")
  +    ctor (gensym "CONSTRUCTOR")]
  +    `(let ((,ctor (clojure-deftype ,classname ,'[] ,@implementations)))
  +       (funcall ,ctor))))
  +
  +;;;;;;;;;;;;;;;;;;;;;;;;;;; core protocols ;;;;;;;;;;;;;
  +
  +;;Need to get back to this guy...multiple arity is not yet implemented...
  +(defprotocol IFn
  +  (-invoke
  +    [this]
  +    [this a]
  +    [this a b]
  +    [this a b c]
  +    [this a b c d]
  +    [this a b c d e]
  +    [this a b c d e f]
  +    [this a b c d e f g]
  +    [this a b c d e f g h]
  +    [this a b c d e f g h i]
  +    [this a b c d e f g h i j]
  +    [this a b c d e f g h i j k]
  +    [this a b c d e f g h i j k l]
  +    [this a b c d e f g h i j k l m]
  +    [this a b c d e f g h i j k l m n]
  +    [this a b c d e f g h i j k l m n o]
  +    [this a b c d e f g h i j k l m n o p]
  +    [this a b c d e f g h i j k l m n o p q]
  +    [this a b c d e f g h i j k l m n o p q s]
  +    [this a b c d e f g h i j k l m n o p q s t]
  +    [this a b c d e f g h i j k l m n o p q s t rest]))
  +
  +
  +;;These work
  +(defprotocol ICounted
  +    (-count [coll] "constant time count"))
  +
  +(defprotocol IEmptyableCollection
  +  (-empty [coll]))
  +
  +(defprotocol ICollection
  +  (-conj [coll o]))
  +
  +(defprotocol IOrdinal
  +    (-index [coll]))
  +
  +;;this will break.  current implementation of defprotocol doesn't allow for 
  +;;multiple arity functions like this.  Need to handle variadic functions...
  +(defprotocol IIndexed
  +  (-nth [coll n] [coll n not-found]))
  +
  +(defprotocol ASeq)
  +
  +(defprotocol ISeq
  +    (-first [coll])
  +    (-rest [coll]))
  +
  +(defprotocol INext
  +  (-next [coll]))
  +
  +(defprotocol ILookup
  +  (-lookup [o k] [o k not-found]))
  +
  +(defprotocol IAssociative
  +  (-contains-key? [coll k])
  +  (-entry-at [coll k])
  +  (-assoc [coll k v]))
  +
  +(defprotocol IMap
  +  (-assoc-ex [coll k v])
  +  (-dissoc [coll k]))
  +
  +(defprotocol IMapEntry
  +  (-key [coll])
  +  (-val [coll]))
  +
  +(defprotocol ISet
  +  (-disjoin [coll v]))
  +
  +(defprotocol IStack
  +  (-peek [coll])
  +  (-pop [coll]))
  +
  +(defprotocol IVector
  +  (-assoc-n [coll n val]))
  +
  +(defprotocol IDeref
  + (-deref [o]))
  +
  +(defprotocol IDerefWithTimeout
  +  (-deref-with-timeout [o msec timeout-val]))
  +
  +(defprotocol IMeta
  +  (-meta [o]))
  +
  +(defprotocol IWithMeta
  +  (-with-meta [o meta]))
  +
  +(defprotocol IReduce
  +    (-reduce [coll f]
  +             [coll f start]))
  +
  +(defprotocol IKVReduce
  +  (-kv-reduce [coll f init]))
  +
  +(defprotocol IEquiv
  +  (-equiv [o other]))
  +
  +(defprotocol IHash
  +  (-hash [o]))
  +
  +(defprotocol ISeqable
  +  (-seq [o]))
  +
  +(defprotocol ISequential
  +  "Marker interface indicating a persistent collection of sequential items")
  +
  +(defprotocol IList
  +  "Marker interface indicating a persistent list")
  +
  +(defprotocol IRecord
  +  "Marker interface indicating a record object")
  +
  +(defprotocol IReversible
  +  (-rseq [coll]))
  +
  +(defprotocol ISorted
  +  (-sorted-seq [coll ascending?])
  +  (-sorted-seq-from [coll k ascending?])
  +  (-entry-key [coll entry])
  +  (-comparator [coll]))
  +
  +;; (defprotocol ^:deprecated IPrintable
  +;;   "Do not use this.  It is kept for backwards compatibility with existing
  +;;    user code that depends on it, but it has been superceded by IPrintWithWriter
  +;;    User code that depends on this should be changed to use -pr-writer instead."
  +;;   (-pr-seq [o opts]))
  +
  +(defprotocol IWriter
  +  (-write [writer s])
  +  (-flush [writer]))
  +
  +(defprotocol IPrintWithWriter
  +  "The old IPrintable protocol's implementation consisted of building a giant
  +   list of strings to concatenate.  This involved lots of concat calls,
  +   intermediate vectors, and lazy-seqs, and was very slow in some older JS
  +   engines.  IPrintWithWriter implements printing via the IWriter protocol, so it
  +   be implemented efficiently in terms of e.g. a StringBuffer append."
  +  (-pr-writer [o writer opts]))
  +
  +(defprotocol IPending
  +  (-realized? [d]))
  +
  +(defprotocol IWatchable
  +  (-notify-watches [this oldval newval])
  +  (-add-watch [this key f])
  +  (-remove-watch [this key]))
  +
  +(defprotocol IEditableCollection
  +  (-as-transient [coll]))
  +
  +
  +(defprotocol ITransientCollection
  +  (-conj! [tcoll val])
  +  (-persistent! [tcoll]))
  +
  +(defprotocol ITransientAssociative
  +  (-assoc! [tcoll key val]))
  +
  +(defprotocol ITransientMap
  +  (-dissoc! [tcoll key]))
  +
  +(defprotocol ITransientVector
  +  (-assoc-n! [tcoll n val])
  +  (-pop! [tcoll]))
  +
  +(defprotocol ITransientSet
  +  (-disjoin! [tcoll v]))
  +
  +(defprotocol IComparable
  +    (-compare [x y]))
  +
  +(defprotocol IChunk
  +  (-drop-first [coll]))
  +
  +(defprotocol IChunkedSeq
  +  (-chunked-first [coll])
  +  (-chunked-rest [coll]))
  +
  +(defprotocol IChunkedNext
  +  (-chunked-next [coll]))
  +
  +
  +;;Extending types to native structures and clojure literals:
  +;;==========================================================
  +
  +(extend-type
  + clclojure.pvector::pvec
  + 
  + ICounted
  + (-count [c] (vector-count c))
  + IIndexed
  + (-nth  [coll n] (nth-vec coll n))
  + (-nth  [coll n not-found] (nth-vec coll n))
  + 
  + IEmptyableCollection
  + (-empty [c] [])
  + ICollection
  + (-conj [coll itm] (vector-conj coll itm))
  + IVector
  + (-assoc-n [coll n val] (vector-assoc coll n val))
  + IStack
  + (-peek [coll]
  +        (when (not (zerop (-count coll) )) (nth-vec coll 0)))
  + (-pop  [coll]  (subvec coll 1))
  + ISeqable
  + (-seq [coll] (vector-to-list coll ))
  + IHash
  + (-hash [o]   (error 'not-implemented))
  + IEquiv
  + (-equiv [o other] (error 'not-implemented))
  +
  + IKVReduce
  + (-kv-reduce [coll f init] (error 'not-implemented))
  + 
  + IReversible
  + (-rseq [coll] (error 'not-implemented))
  + IChunk
  + (-drop-first [coll] (error 'not-implemented))
  + IChunkedSeq
  + (-chunked-first [coll] (error 'not-implemented))
  + (-chunked-rest [coll] (error 'not-implemented))
  + IChunkedNext
  + (-chunked-next [coll] (error 'not-implemented)))
  + 
  +
  +
  +(extend-type  symbol 
  +    IMeta
  +    (-meta [obj] (symbol-meta obj))
  +    IWithMeta
  +    (-with-meta [obj m] (with-symbol-meta obj m) obj))
  +
  +;;subvector impls...
  +(extend-type
  + clclojure.pvector::subvector
  + 
  + ICounted
  + (-count [c] (vector-count c))
  +
  + IEmptyableCollection
  + (-empty [c] [])
  + ICollection
  + (-conj [coll itm] (vector-conj coll itm))
  + IVector
  + (-assoc-n [coll n val] (vector-assoc coll n val))
  + IStack
  + (-peek [coll]
  +        (when (not (zerop (-count coll) )) (nth-vec coll 0)))
  + (-pop  [coll]  (subvec coll 1))
  + ISeqable
  + (-seq [coll] (vector-to-list )) ;poorly implemented.  should be arrayseq
  + IHash
  + (-hash [o]   (error 'not-implemented))
  + IEquiv
  + (-equiv [o other] (error 'not-implemented))
  + IKVReduce
  + (-kv-reduce [coll f init] (error 'not-implemented))
  +
  + IReversible
  + (-rseq [coll] (error 'not-implemented))
  + IChunk
  + (-drop-first [coll] (error 'not-implemented))
  + IChunkedSeq
  + (-chunked-first [coll] (error 'not-implemented))
  + (-chunked-rest [coll] (error 'not-implemented))
  + IChunkedNext
  + (-chunked-next [coll] (error 'not-implemented))
  + )
  +
  +;;list operations.
  +(extend-type
  + cons
  + ICounted
  + (-count [c] (length c))
  +
  + IEmptyableCollection
  + (-empty [c] '())
  + ICollection
  + (-conj [coll itm] (cons itm coll))
  + IStack
  + (-peek [coll]  (first coll))
  + (-pop  [coll]  (rest coll))
  + ISeqable
  + (-seq [coll] (sequences::seq coll))
  + IHash
  + (-hash [o]   (sxhash o))
  + IEquiv
  + (-equiv [o other] (error 'not-implemented))
  + IMapEntry
  + (-key [coll] (first coll))
  + (-val [coll] (second coll))
  + )
  +
  +(extend-type
  + sequences::lazyseq
  + ICounted
  + (-count [c] (length c))
  +
  + IEmptyableCollection
  + (-empty [c] '())
  + ICollection
  + (-conj [coll itm] (sequences::cons itm coll))
  + IStack
  + (-peek [coll]  (sequences::first coll))
  + (-pop  [coll]  (sequences::rest coll))
  + ISeqable
  + (-seq [coll] (sequences::seq coll))
  + IHash
  + (-hash [o]   (sxhash o)) ;;poorly implemented...
  + IEquiv
  + (-equiv [o other] (error 'not-implemented))
  + IMapEntry
  + (-key [coll] (sequences::first coll))
  + (-val [coll] (sequences::rest coll))
  + )
  +
  +(extend-type
  + sequences::funcseq
  + ICounted
  + (-count [c] (length c))
  +
  + IEmptyableCollection
  + (-empty [c] '())
  + ICollection
  + (-conj [coll itm] (sequences::cons itm coll))
  + IStack
  + (-peek [coll]  (sequences::first coll))
  + (-pop  [coll]  (sequences::rest coll))
  + ISeqable
  + (-seq [coll] (sequences::seq coll))
  + IHash
  + (-hash [o]   (sxhash o)) ;;poorly implemented...
  + IEquiv
  + (-equiv [o other] (error 'not-implemented))
  + IMapEntry
  + (-key [coll] (sequences::first coll))
  + (-val [coll] (sequences::rest coll))
  + )
  +
  +(extend-type
  + clclojure.cowmap::cowmap
  +
  + ICounted
  + (-count [c] (map-count c))
  +
  + IEmptyableCollection
  + (-empty [c] {})
  +
  + ICollection
  + (-conj [coll itm] (map-assoc coll (first itm) (second itm)))
  +
  + ISeqable
  + (-seq [coll] (map-seq coll))
  + 
  + IAssociative
  + (-contains-key? [coll k] (map-contains? coll k))
  + (-entry-at [coll k]      (map-entry-at coll k))
  + (-assoc [coll k v]       (map-assoc coll k v))
  +
  + IMap
  + (-assoc-ex [coll k v]  (error 'not-implemented)) ;;apparently vestigial
  + (-dissoc   [coll k]    (map-dissoc coll k))
  + 
  + IHash
  + (-hash [o]   (error 'not-implemented))
  + IEquiv
  + (-equiv [o other] (error 'not-implemented))
  + IKVReduce
  + (-kv-reduce [coll f init] (error 'not-implemented)))
  + ;; IChunk
  + ;; (-drop-first [coll] (error 'not-implemented))
  + ;; IChunkedSeq
  + ;; (-chunked-first [coll] (error 'not-implemented))
  + ;; (-chunked-rest [coll] (error 'not-implemented))
  + ;; IChunkedNext
  + ;; (-chunked-next [coll] (error 'not-implemented))
  + 
  +;;friendly map printing
  +(defmethod print-object ((obj hash-table) stream)
  +  (common-utils::print-map  obj stream))
  +
  +;;map printing compatibility
  +(defmethod print-object ((obj clclojure.cowmap::cowmap) stream)
  +  (common-utils::print-map (cowmap-table obj) stream))
  +
  +(defmacro when-let [binding & args]
  +  )
  +;;need to implement arrayseq...
  +(defn seq [coll] (-seq coll))
  +
  +(defn take [n coll]
  +  (sequences:take n (seq  coll)))
  +
  +(defn drop [n coll]
  +  (sequences:drop n (seq coll)))
  +
  +(defn vec [coll]
  +  (if (vector? coll) coll
  +      (sequences:apply #'persistent-vector (seq coll))))
  +
  +;;a little lame...
  +(defn conj [coll x]
  +  (-conj coll x))
  +
  +(defn empty [coll] (-empty coll))
  +
  +;; "Returns a new coll consisting of to-coll with all of the items of
  +;;   from-coll conjoined. A transducer may be supplied."
  +;; {:added "1.0"
  +;; :static true}
  +(defn into
  +  ([] [])
  +  ([to] to)
  +  ([to from]
  +       (if nil ;(instance? clojure.lang.IEditableCollection to)
  +           (with-meta (persistent! (reduce conj! (transient to) from)) (meta to))
  +           (sequences:reduce conj to (seq  from))))
  +  ;; ([to xform from]
  +  ;;      (if nil ;(instance? clojure.lang.IEditableCollection to)
  +  ;;          (with-meta (persistent! (transduce xform conj! (transient to) from)) (meta to))
  +  ;;          (transduce xform conj to from)))
  +  )
  +
  +;; "Returns a lazy sequence consisting of the result of applying f to
  +;;   the set of first items of each coll, followed by applying f to the
  +;;   set of second items in each coll, until any one of the colls is
  +;;   exhausted.  Any remaining items in other colls are ignored. Function
  +;;   f should accept number-of-colls arguments. Returns a transducer when
  +;;   no collection is provided."
  +;; {:added "1.0"
  +;; :static true}
  +;; (defn map
  +;;   ([f]
  +;;    (fn [rf]
  +;;        (fn
  +;;         ([] (rf))
  +;;         ([result] (rf result))
  +;;         ([result input]
  +;;                  (rf result (f input)))
  +;;         ([result input & inputs]
  +;;                  (rf result (apply f input inputs))))))
  +;;   ([f coll]
  +;;       (lazy-seq
  +;;        (when-let [s (seq coll)]
  +;;          (if (chunked-seq? s)
  +;;              (let [c (chunk-first s)
  +;;                size (int (count c))
  +;;                b (chunk-buffer size)]
  +;;                (dotimes [i size]
  +;;                  (chunk-append b (f (.nth c i))))
  +;;                (chunk-cons (chunk b) (map f (chunk-rest s))))
  +;;              (cons (f (first s)) (map f (rest s)))))))
  +;;   ([f c1 c2]
  +;;       (lazy-seq
  +;;        (let [s1 (seq c1) s2 (seq c2)]
  +;;          (when (and s1 s2)
  +;;            (cons (f (first s1) (first s2))
  +;;                  (map f (rest s1) (rest s2)))))))
  +;;   ([f c1 c2 c3]
  +;;       (lazy-seq
  +;;        (let [s1 (seq c1) s2 (seq c2) s3 (seq c3)]
  +;;          (when (and  s1 s2 s3)
  +;;            (cons (f (first s1) (first s2) (first s3))
  +;;                  (map f (rest s1) (rest s2) (rest s3)))))))
  +;;   ([f c1 c2 c3 & colls]
  +;;       (let [step (fn step [cs]
  +;;                      (lazy-seq
  +;;                       (let [ss (map seq cs)]
  +;;                         (when (every? identity ss)
  +;;                           (cons (map first ss) (step (map rest ss)))))))]
  +;;         (map #(apply f %) (step (conj colls c3 c2 c1))))))
  +
  +(defn concat
  +    ([] nil)
  +    ([x] x)
  +    ([x y] (sequences:concat (seq x) (seq y)))
  +  ([x y & zs]
  +      (sequences:apply #'sequences:concat
  +        (sequences:map #'seq (list* x y zs)))))
   ;;need destructure...
   
   ;; "Evaluates the exprs in a lexical context in which the symbols in
   ;;   the binding-forms are bound to their respective init-exprs or parts
   ;;   therein. Acts as a recur target."
  -;; (defmacro loop (bindings &rest body)
  +(defmacro loop* (bindings &rest body)
  +  ;; (assert-args
  +  ;;  (vector? bindings) "a vector for its binding"
  +  ;;  (even? (count bindings)) "an even number of forms in binding vector")          
  +  (let [vs (take 2 (drop 1 bindings))
  +    bs (take-nth 2 bindings)
  +    gs (map (fn [b] (if (symbol? b) b (gensym))) bs)
  +    bfs (reduce1 (fn [ret [b v g]]
  +                     (if (symbol? b)
  +                         (conj ret g v)
  +                         (conj ret g v b g)))
  +                 [] (map vector bs vs gs))]
  +    `(let ~bfs
  +       (loop* ~(vec (interleave gs gs))
  +              (let ~(vec (interleave bs gs))
  +                ~@body)))))
  +
  +;; (defmacro loop* (bindings &rest body)
   ;;   ;; (assert-args
   ;;   ;;  (vector? bindings) "a vector for its binding"
   ;;   ;;  (even? (count bindings)) "an even number of forms in binding vector")
  
positive.code: ;;              (loop* ~(vec (interleave gs gs))
  ;;                     (let ~(vec (interleave bs gs))
  ;;                       ~@body)))))))
  
  ;; (comment 
  
  ;; (defmacro fn  (& sigs) 
  
negative.code: ;;         (meta &form))))
  ;; )
  
  ;;conflicts with :common-lisp
  (comment 
   (defn nth
       ([coll index]
              (-nth coll index))
     ([coll index not-found]
            (-nth coll index not-found)))
  
   (defn partition [n xs]))
  
  ;; (defn destructure [bindings]
  ;;   (let [bents (partition 2 bindings)
  ;;     pb (fn pb [bvec b v]
  ;;            (let [pvec
  ;;              (fn [bvec b val]
  ;;                  (let [gvec (gensym "vec__")
  ;;                    gseq (gensym "seq__")
  ;;                    gfirst (gensym "first__")
  ;;                    has-rest (some #{'&} b)]
  ;;                    (loop [ret (let [ret (conj bvec gvec val)]
  ;;                                 (if has-rest
  ;;                                     (conj ret gseq (list `seq gvec))
  ;;                                     ret))
  ;;                          n 0
  ;;                          bs b
  ;;                          seen-rest? false]
  ;;                          (if (seq bs)
  ;;                              (let [firstb (first bs)]
  ;;                                (cond
  ;;                                  (= firstb '&) (recur (pb ret (second bs) gseq)
  ;;                                                       n
  ;;                                                       (nnext bs)
  ;;                                                       true)
  ;;                                  (= firstb :as) (pb ret (second bs) gvec)
  ;;                                  :else (if seen-rest?
  ;;                                            (throw (new Exception "Unsupported binding form, only :as can follow & parameter"))
  ;;                                            (recur (pb (if has-rest
  ;;                                                           (conj ret
  ;;                                                                 gfirst `(first ~gseq)
  ;;                                                                 gseq `(next ~gseq))
  ;;                                                           ret)
  ;;                                                       firstb
  ;;                                                       (if has-rest
  ;;                                                           gfirst
  ;;                                                           (list `nth gvec n nil)))
  ;;                                                   (inc n)
  ;;                                                   (next bs)
  ;;                                                   seen-rest?))))
  ;;                              ret))))
  ;;              pmap
  ;;              (fn [bvec b v]
  ;;                  (let [gmap (gensym "map__")
  ;;                    gmapseq (with-meta gmap {:tag 'clojure.lang.ISeq})
  ;;                    defaults (:or b)]
  ;;                    (loop [ret (-> bvec (conj gmap) (conj v)
  ;;                                   (conj gmap) (conj `(if (seq? ~gmap) (clojure.lang.PersistentHashMap/create (seq ~gmapseq)) ~gmap))
  ;;                                   ((fn [ret]
  ;;                                        (if (:as b)
  ;;                                            (conj ret (:as b) gmap)
  ;;                                            ret))))
  ;;                          bes (let [transforms
  ;;                                (reduce1
  ;;                                 (fn [transforms mk]
  ;;                                     (if (keyword? mk)
  ;;                                         (let [mkns (namespace mk)
  ;;                                           mkn (name mk)]
  ;;                                           (cond (= mkn "keys") (assoc transforms mk #(keyword (or mkns (namespace %)) (name %)))
  ;;                                                 (= mkn "syms") (assoc transforms mk #(list `quote (symbol (or mkns (namespace %)) (name %))))
  ;;                                                 (= mkn "strs") (assoc transforms mk str)
  ;;                                                 :else transforms))
  ;;                                         transforms))
  ;;                                 {}
  ;;                                 (keys b))]
  ;;                                (reduce1
  ;;                                 (fn [bes entry]
  ;;                                     (reduce1 #(assoc %1 %2 ((val entry) %2))
  ;;                                              (dissoc bes (key entry))
  ;;                                              ((key entry) bes)))
  ;;                                 (dissoc b :as :or)
  ;;                                 transforms))]
  ;;                          (if (seq bes)
  ;;                              (let [bb (key (first bes))
  ;;                                bk (val (first bes))
  ;;                                local (if (instance? clojure.lang.Named bb) (with-meta (symbol nil (name bb)) (meta bb)) bb)
  ;;                                bv (if (contains? defaults local)
  ;;                                       (list `get gmap bk (defaults local))
  ;;                                       (list `get gmap bk))]
  ;;                                (recur (if (ident? bb)
  ;;                                           (-> ret (conj local bv))
  ;;                                           (pb ret bb bv))
  ;;                                       (next bes)))
  ;;                              ret))))]
  ;;              (cond
  ;;                (symbol? b) (-> bvec (conj b) (conj v))
  ;;                (vector? b) (pvec bvec b v)
  ;;                (map? b) (pmap bvec b v)
  ;;                :else (throw (new Exception (str "Unsupported binding form: " b))))))
  ;;     process-entry (fn [bvec b] (pb bvec (first b) (second b)))]
  ;;     (if (every? symbol? (map first bents))
  ;;         bindings
  ;;         (reduce1 process-entry [] bents))))
  