Commits

Meikel Brandmeyer committed 9a5b358

Major changes: adapt to new AOT compilation

  • Participants
  • Parent commits f609b94

Comments (0)

Files changed (18)

LICENSE

-Copyright 2008 (c) Meikel Brandmeyer.
-All rights reserved.
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
+Copyright 2008 (c) Meikel Brandmeyer.
+All rights reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.

Makefile

-PROJECT := lazy-map
-
-SRCDIR  := src
-DISTDIR := dist
-
-JAVASRC != cd ${SRCDIR} && find * -type f -name \*.java
-CLJSRC  != cd ${SRCDIR} && find * -type f \( -name \*.clj -and -not -name \*.gen.clj \)
-GCCLJSRC!= cd ${SRCDIR} && find * -type f -name \*.gen.clj
-DIRS    != cd ${SRCDIR} && find * -type d
-
-VERSION != shtool version -d short version.txt
-JAR     := ${PROJECT}-${VERSION}.jar
-TGZ     := ${PROJECT}-${VERSION}.tar.gz
-
-all: jar
-
-release: jar tarball
-
-jar: ${JAR}
-
-tarball: ${TGZ}
-
-test: jar
-	env CLASSPATH=${JAR}:$${CLASSPATH} prove t
-
-doc: compile
-	( cat README.txt.in; \
-	  java clojure.lang.Script gen-docs.clj ) > README.txt
-
-clean:
-	rm -rf ${DISTDIR} ${JAR} ${TGZ} README.txt
-
-compile: ${CLJSRC:C/^/dist\//} ${GCCLJSRC:R:R:C/^/dist\//:C/$/.class/}
-
-bump-version:
-	shtool version -l txt -n ${PROJECT} -i v version.txt
-
-bump-revision:
-	shtool version -l txt -n ${PROJECT} -i r version.txt
-
-bump-level:
-	shtool version -l txt -n ${PROJECT} -i l version.txt
-
-.for _clj in ${CLJSRC}
-dist/${_clj}: src/${_clj} ${DISTDIR}
-	shtool install -c src/${_clj} dist/${_clj}
-.endfor
-
-.for _clj in ${GCCLJSRC}
-dist/${_clj:R:R}.class: src/${_clj} ${DISTDIR}
-	java clojure.lang.Script gen-class.clj -- ${DISTDIR} ${_clj}
-.endfor
-
-${JAR}: doc compile
-	cp README.txt ${DISTDIR}
-	cp LICENSE ${DISTDIR}
-	jar cf ${JAR} -C ${DISTDIR} .
-
-${TGZ}: doc
-	shtool tarball -c "gzip -9" -o ${TGZ} \
-		-e '\.DS_Store,${DISTDIR},\.jar,\.hg,\.tar\.gz' .
-
-${DISTDIR}:
-	shtool mkdir -p ${DISTDIR}
-	@for dir in ${DIRS}; do \
-		echo shtool mkdir -p ${DISTDIR}/$${dir}; \
-		shtool mkdir -p ${DISTDIR}/$${dir}; \
-	done
-
-.PHONY: all release jar tarball test doc clean compile
+          ______                     ______  ___
+          ___  / ______ __________  ____   |/  /_____ ________
+          __  /  _  __ `/__  /_  / / /_  /|_/ /_  __ `/__  __ \
+          _  /___/ /_/ /__  /_  /_/ /_  /  / / / /_/ /__  /_/ /
+          /_____/\__,_/ _____/\__, / /_/  /_/  \__,_/ _  .___/
+                             /____/                   /_/
+
+LazyMap is a transparent wrapper around the map types of Clojure. It works
+similar to lazy-cons for lists: the value associated with a key via lazy-assoc
+is not evaluated until it is actually accessed. So if the value is dissoc'd
+before it is accessed the code necessary to generate the value is not executed
+at all.
+
+Meikel Brandmeyer <mb@kotka.de>,
+Frankfurt am Main, 2008

README.txt.in

-          ______                     ______  ___
-          ___  / ______ __________  ____   |/  /_____ ________
-          __  /  _  __ `/__  /_  / / /_  /|_/ /_  __ `/__  __ \
-          _  /___/ /_/ /__  /_  /_/ /_  /  / / / /_/ /__  /_/ /
-          /_____/\__,_/ _____/\__, / /_/  /_/  \__,_/ _  .___/
-                             /____/                   /_/
-
-LazyMap is a transparent wrapper around the map types of Clojure. It works
-similar to lazy-cons for lists: the value associated with a key via lazy-assoc
-is not evaluated until it is actually accessed. So if the value is dissoc'd
-before it is accessed the code necessary to generate the value is not executed
-at all.
-
-Meikel Brandmeyer <mb@kotka.de>,
-Frankfurt am Main, 2008
-
-Reference Documentation in alphabetical order:
-
+<project name="lazymap" default="jar">
+
+	<description>
+		Build with "ant jar".
+	</description>
+
+	<property environment="env"/>
+
+	<property name="src" location="src"/>
+	<property name="build" location="classes"/>
+	<property name="lazymap_jar" location="lazymap.jar"/>
+	<property name="clojure.lib" location="${env.CLOJURE_LIB}"/>
+
+	<path id="clojurelib">
+		<fileset dir="${clojure.lib}" includes="**/*.jar"/>
+	</path>
+
+	<target name="init">
+		<tstamp/>
+		<mkdir dir="${build}"/>
+	</target>
+
+	<target name="aot" depends="init"
+		description="Compile Clojure sources.">
+		<java classname="clojure.lang.Compile">
+			<classpath>
+				<path location="${build}"/>
+				<path location="${src}"/>
+				<path refid="clojurelib"/>
+			</classpath>
+			<sysproperty key="clojure.compile.path"
+				value="${build}"/>
+			<arg value="de.kotka.lazymap.LazyMapEntry"/>
+			<arg value="de.kotka.lazymap.LazyMapSeq"/>
+			<arg value="de.kotka.lazymap.LazyMap"/>
+			<arg value="de.kotka.lazymap"/>
+		</java>
+	</target>
+
+	<target name="jar" depends="aot"
+		description="Create jar file.">
+		<jar jarfile="${lazymap_jar}" basedir="${build}">
+			<fileset dir="${src}" includes="**/*.clj"/>
+			<path location="README.txt"/>
+			<path location="LICENSE.txt"/>
+			<manifest>
+				<attribute name="Class-Path" value="."/>
+			</manifest>
+		</jar>
+	</target>
+
+	<target name="clean"
+		description="Remove autogenerated files and directories.">
+		<delete dir="${build}"/>
+		<delete file="${lazymap_jar}"/>
+	</target>
+
+</project>

gen-class.clj

-;-
-; Copyright 2008 (c) Meikel Brandmeyer.
-; All rights reserved.
-;
-; Permission is hereby granted, free of charge, to any person obtaining a copy
-; of this software and associated documentation files (the "Software"), to deal
-; in the Software without restriction, including without limitation the rights
-; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-; copies of the Software, and to permit persons to whom the Software is
-; furnished to do so, subject to the following conditions:
-;
-; The above copyright notice and this permission notice shall be included in
-; all copies or substantial portions of the Software.
-;
-; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-; THE SOFTWARE.
-
-(def *builddir* (first *command-line-args*))
-
-(doseq c (rest *command-line-args*)
-  (load-file (str "src/" c)))

gen-docs.clj

-;-
-; Copyright 2008 (c) Meikel Brandmeyer.
-; All rights reserved.
-;
-; Permission is hereby granted, free of charge, to any person obtaining a copy
-; of this software and associated documentation files (the "Software"), to deal
-; in the Software without restriction, including without limitation the rights
-; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-; copies of the Software, and to permit persons to whom the Software is
-; furnished to do so, subject to the following conditions:
-;
-; The above copyright notice and this permission notice shall be included in
-; all copies or substantial portions of the Software.
-;
-; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-; THE SOFTWARE.
-
-(require 'de.kotka.lazymap)
-
-(let [c  (proxy [java.util.Comparator] []
-           (compare
-             [a b]
-             (let [as (str a)
-                   bs (str b)]
-               (. as compareTo bs))))
-      vs (map (fn [[n v]] v) (ns-publics (find-ns 'de.kotka.lazymap)))]
-  (doseq v (sort c vs)
-    (let [d ((meta v) :doc)]
-      (when d (print-doc v)))))

src/de/kotka/lazymap.clj

+;-
+; Copyright 2008 (c) Meikel Brandmeyer.
+; All rights reserved.
+;
+; Permission is hereby granted, free of charge, to any person obtaining a copy
+; of this software and associated documentation files (the "Software"), to deal
+; in the Software without restriction, including without limitation the rights
+; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+; copies of the Software, and to permit persons to whom the Software is
+; furnished to do so, subject to the following conditions:
+;
+; The above copyright notice and this permission notice shall be included in
+; all copies or substantial portions of the Software.
+;
+; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+; THE SOFTWARE.
+
+(clojure.core/ns de.kotka.lazymap
+  (:import
+     (de.kotka.lazymap LazyMap)))
+
+(defn- quote-values
+  [kvs]
+  (map (fn [[k v]] [k `(delay ~v)]) (partition 2 kvs)))
+
+(defn- make-map
+  [t kvs]
+  `(new LazyMap (apply ~t (concat ~@(quote-values kvs)))))
+
+(defmacro lazy-assoc
+  "<lazy-assoc> associates new values to the given keys in the given lazy map.
+  The values are not evaluated, before their first retrieval. They are
+  evaluated at most once."
+  [m & kvs]
+  `(reduce (fn [m# [k# v#]]
+             (. m# ~'lazyAssoc k# v#))
+           ~m (list ~@(quote-values kvs))))
+
+(defmacro lazy-hash-map
+  "<lazy-hash-map> creates a map. The values are not evaluated before their
+  first retrieval. Each value is evaluated at most once. The underlying map
+  is a hash map."
+  [& kvs]
+  (make-map `hash-map kvs))
+
+(defmacro lazy-sorted-map
+  "<lazy-sorted-map> creates a map. The values are not evaluated before their
+  first retrieval. Each value is evaluated at most once. The underlying map
+  is a sorted map."
+  [& kvs]
+  (make-map `sorted-map kvs))
+
+(defmacro lazy-struct-map
+  "<lazy-struct-map> creates a map. The values are not evaluated before their
+  first retrieval. Each value is evaluated at most once. The underlying map
+  is a struct map according to the provided structure s."
+  [s & kvs]
+  (make-map `(fn [& kvs#] (apply struct-map ~s kvs#)) kvs))
+
+(defmacro lazy-struct
+  "<lazy-struct> creates a map. The values are not evaluated before their
+  first retrieval. Each value is evaluated at most once. The underlying map
+  is a struct map according to the provided structure s. As with Clojure's
+  <struct> the values have to appear in the order of the keys in the structure."
+  [s & vs]
+  (let [vs (map (fn [v] `(delay ~v)) vs)]
+    `(new LazyMap (struct ~s ~@vs))))

src/de/kotka/lazymap/LazyMap.clj

+;-
+; Copyright 2008 (c) Meikel Brandmeyer.
+; All rights reserved.
+;
+; Permission is hereby granted, free of charge, to any person obtaining a copy
+; of this software and associated documentation files (the "Software"), to deal
+; in the Software without restriction, including without limitation the rights
+; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+; copies of the Software, and to permit persons to whom the Software is
+; furnished to do so, subject to the following conditions:
+;
+; The above copyright notice and this permission notice shall be included in
+; all copies or substantial portions of the Software.
+;
+; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+; THE SOFTWARE.
+
+(clojure.core/ns de.kotka.lazymap.LazyMap
+  (:gen-class
+     :init         init
+     :state        theMap
+     :methods      [[lazyAssoc [Object Object] clojure.lang.IPersistentMap]]
+     :implements   [clojure.lang.IPersistentMap clojure.lang.IFn
+                    clojure.lang.IObj]
+     :constructors {[clojure.lang.IPersistentMap] []})
+  (:import
+     (clojure.lang SeqIterator IMapEntry IPersistentVector IObj)))
+
+(defn- -init
+  [theMap]
+  [[] theMap])
+
+(defn- -lazyAssoc
+  [this k v]
+  (new de.kotka.lazymap.LazyMap (-> this .theMap (.assoc k v))))
+
+; IObj
+(defn- -meta
+  [this]
+  (-> this .theMap .meta))
+
+(defn- -withMeta
+  [this meta-data]
+  (new de.kotka.lazymap.LazyMap (-> this .theMap (.withMeta meta-data))))
+
+; IPersistentMap
+(defn- -assoc
+  [this k v]
+  (new de.kotka.lazymap.LazyMap (-> this .theMap (.assoc k (delay v)))))
+
+(defn- -assocEx
+  [this k v]
+  (when (. this containsKey k)
+    (throw (new Exception (str "Key alread present: " k))))
+  (. this assoc k v))
+
+(defn- -without
+  [this k]
+  (new de.kotka.lazymap.LazyMap (-> this .theMap (.without k))))
+
+; Associative
+(defn- -containsKey
+  [this k]
+  (-> this .theMap (.containsKey k)))
+
+(defn- -entryAt
+  [this k]
+  (new de.kotka.lazymap.LazyMapEntry k (-> this .theMap (.valAt k))))
+
+(defn- -valAt
+  ([this k]
+   (. this valAt k nil))
+  ([this k nf]
+   (if (-> this .theMap (.containsKey k))
+     (force (-> this .theMap (.valAt k)))
+     nf)))
+
+; Iterable
+(defn- -iterator
+  [this]
+  (new SeqIterator (. this seq)))
+
+; IPersistentCollection
+(defn- -count
+  [this]
+  (-> this .theMap .count))
+
+(defn- -seq
+  [this]
+  (when-let [inner-seq (-> this .theMap .seq)]
+    (new de.kotka.lazymap.LazyMapSeq inner-seq)))
+
+(defn- -cons
+  [this o]
+  (cond
+    (instance? de.kotka.lazymap.LazyMapEntry o) (let [k (. o getKey)
+                                     v (. o getRawValue)]
+                                 (. this lazyAssoc k v))
+    (instance? IMapEntry o)    (let [k (. o getKey)
+                                     v (. o getValue)]
+                                 (. this assoc k (delay v)))
+    (instance? IPersistentVector o)
+                               (if (= (count o) 2)
+                                 (let [k (o 0)
+                                       v (o 1)]
+                                   (. this assoc k (delay v)))
+                                 (throw (new IllegalArgumentException
+                                             "Vector arg to map conj must be a pair")))
+    :else                      (reduce #(. %1 cons %2) this o)))
+
+(defn- -empty
+  [this]
+  (new de.kotka.lazymap.LazyMap (-> this .theMap .empty)))
+
+; IFn
+(defn- -invoke
+  [this & ks]
+  (. this valAt (first ks)))
+
+(defn- -applyTo
+  [this ks]
+  (. this valAt (first ks)))

src/de/kotka/lazymap/LazyMapClass.clj

-;-
-; Copyright 2008 (c) Meikel Brandmeyer.
-; All rights reserved.
-;
-; Permission is hereby granted, free of charge, to any person obtaining a copy
-; of this software and associated documentation files (the "Software"), to deal
-; in the Software without restriction, including without limitation the rights
-; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-; copies of the Software, and to permit persons to whom the Software is
-; furnished to do so, subject to the following conditions:
-;
-; The above copyright notice and this permission notice shall be included in
-; all copies or substantial portions of the Software.
-;
-; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-; THE SOFTWARE.
-
-(clojure/in-ns 'de.kotka.lazymap)
-(clojure/refer 'clojure)
-
-(import '(clojure.lang SeqIterator IMapEntry IPersistentVector IObj)
-        '(de.kotka.lazymap LazyMapClass LazyMapSeq))
-
-(defn- LazyMapClass-init
-  [theMap]
-  [[] theMap])
-
-(defn- LazyMapClass-lazyAssoc
-  [this k v]
-  (new LazyMapClass (-> this .theMap (.assoc k v))))
-
-; IObj
-(defn- LazyMapClass-meta
-  [this]
-  (-> this .theMap .meta))
-
-(defn- LazyMapClass-withMeta
-  [this meta-data]
-  (new LazyMapClass (-> this .theMap (.withMeta meta-data))))
-
-; IPersistentMap
-(defn- LazyMapClass-assoc
-  [this k v]
-  (new LazyMapClass (-> this .theMap (.assoc k (delay v)))))
-
-(defn- LazyMapClass-assocEx
-  [this k v]
-  (when (. this containsKey k)
-    (throw (new Exception (str "Key alread present: " k))))
-  (. this assoc k v))
-
-(defn- LazyMapClass-without
-  [this k]
-  (new LazyMapClass (-> this .theMap (.without k))))
-
-; Associative
-(defn- LazyMapClass-containsKey
-  [this k]
-  (-> this .theMap (.containsKey k)))
-
-(defn- LazyMapClass-entryAt
-  [this k]
-  (new LazyMapEntry k (-> this .theMap (.valAt k))))
-
-(defn- LazyMapClass-valAt
-  ([this k]
-   (. this valAt k nil))
-  ([this k nf]
-   (if (-> this .theMap (.containsKey k))
-     (force (-> this .theMap (.valAt k)))
-     nf)))
-
-; Iterable
-(defn- LazyMapClass-iterator
-  [this]
-  (new SeqIterator (. this seq)))
-
-; IPersistentCollection
-(defn- LazyMapClass-count
-  [this]
-  (-> this .theMap .count))
-
-(defn- LazyMapClass-seq
-  [this]
-  (LazyMapSeq-createSeq (-> this .theMap .seq)))
-
-(defn- LazyMapClass-cons
-  [this o]
-  (cond
-    (instance? LazyMapEntry o) (let [k (. o getKey)
-                                     v (. o getRawValue)]
-                                 (. this lazyAssoc k v))
-    (instance? IMapEntry o)    (let [k (. o getKey)
-                                     v (. o getValue)]
-                                 (. this assoc k (delay v)))
-    (instance? IPersistentVector o)
-                               (if (= (count o) 2)
-                                 (let [k (o 0)
-                                       v (o 1)]
-                                   (. this assoc k (delay v)))
-                                 (throw (new IllegalArgumentException
-                                             "Vector arg to map conj must be a pair")))
-    :else                      (reduce #(. %1 cons %2) this o)))
-
-(defn- LazyMapClass-empty
-  [this]
-  (new LazyMapClass (-> this .theMap .empty)))
-
-; IFn
-(defn- LazyMapClass-invoke
-  [this & ks]
-  (. this valAt (first ks)))
-
-(defn- LazyMapClass-applyTo
-  [this ks]
-  (. this valAt (first ks)))

src/de/kotka/lazymap/LazyMapClass.gen.clj

-;-
-; Copyright 2008 (c) Meikel Brandmeyer.
-; All rights reserved.
-;
-; Permission is hereby granted, free of charge, to any person obtaining a copy
-; of this software and associated documentation files (the "Software"), to deal
-; in the Software without restriction, including without limitation the rights
-; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-; copies of the Software, and to permit persons to whom the Software is
-; furnished to do so, subject to the following conditions:
-;
-; The above copyright notice and this permission notice shall be included in
-; all copies or substantial portions of the Software.
-;
-; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-; THE SOFTWARE.
-
-(gen-and-save-class *builddir* 'de.kotka.lazymap.LazyMapClass
-  :init         'init
-  :state        'theMap
-  :methods      [['lazyAssoc [Object Object] clojure.lang.IPersistentMap]]
-  :implements   [clojure.lang.IPersistentMap clojure.lang.IFn clojure.lang.IObj]
-  :constructors {[clojure.lang.IPersistentMap] []})

src/de/kotka/lazymap/LazyMapEntry.clj

 ; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 ; THE SOFTWARE.
 
-(clojure/in-ns 'de.kotka.lazymap)
-(clojure/refer 'clojure)
+(clojure.core/ns de.kotka.lazymap.LazyMapEntry
+  (:gen-class
+     :init         init
+     :state        theState
+     :methods      [[getRawValue [] clojure.lang.Delay]]
+     :implements   [clojure.lang.IMapEntry]
+     :constructors {[Object Object] []}))
 
 (defstruct
   #^{:private true}
-  LazyMapEntry-state
+  entry-state
   :theKey :theValue)
 
-(defn- LazyMapEntry-init
+(defn- -init
   [k v]
-  [[] (struct LazyMapEntry-state k v)])
+  [[] (struct entry-state k v)])
 
-(defn- LazyMapEntry-getKey
+(defn- -getKey
   [this]
   ((. this theState) :theKey))
 
-(defn- LazyMapEntry-key
+(defn- -key
   [this]
-  (. this getKey))
+  (.getKey this))
 
-(defn- LazyMapEntry-getValue
+(defn- -getValue
   [this]
-  (force (. this getRawValue)))
+  (force (.getRawValue this)))
 
-(defn- LazyMapEntry-val
+(defn- -val
   [this]
-  (. this getValue))
+  (.getValue this))
 
-(defn- LazyMapEntry-getRawValue
+(defn- -getRawValue
   [this]
-  ((. this theState) :theValue))
+  ((.theState this) :theValue))
 
-(defn- LazyMapEntry-toString
+(defn- -toString
   [this]
-  (str \[ (. this key) \space (. this val) \]))
+  (str \[ (.key this) \space (.val this) \]))

src/de/kotka/lazymap/LazyMapEntry.gen.clj

-;-
-; Copyright 2008 (c) Meikel Brandmeyer.
-; All rights reserved.
-;
-; Permission is hereby granted, free of charge, to any person obtaining a copy
-; of this software and associated documentation files (the "Software"), to deal
-; in the Software without restriction, including without limitation the rights
-; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-; copies of the Software, and to permit persons to whom the Software is
-; furnished to do so, subject to the following conditions:
-;
-; The above copyright notice and this permission notice shall be included in
-; all copies or substantial portions of the Software.
-;
-; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-; THE SOFTWARE.
-
-(gen-and-save-class *builddir* 'de.kotka.lazymap.LazyMapEntry
-  :init         'init
-  :state        'theState
-  :methods      [['getRawValue [] clojure.lang.Delay]]
-  :implements   [clojure.lang.IMapEntry]
-  :constructors {[Object Object] []})

src/de/kotka/lazymap/LazyMapSeq.clj

 ; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 ; THE SOFTWARE.
 
-(clojure/in-ns 'de.kotka.lazymap)
-(clojure/refer 'clojure)
+(clojure.core/ns de.kotka.lazymap.LazyMapSeq
+  (:gen-class
+     :init         init
+     :state        theSeq
+     :implements   [clojure.lang.ISeq clojure.lang.Sequential]
+     :constructors {[clojure.lang.ISeq] []})
+  (:import
+     (clojure.lang Cons)))
 
-(use    'clojure.contrib.def)
-(import '(clojure.lang Cons)
-        '(de.kotka.lazymap LazyMapSeq LazyMapEntry))
-
-(defn- LazyMapSeq-createSeq
-  [theSeq]
-  (when theSeq
-    (new LazyMapSeq theSeq)))
-
-(defn- LazyMapSeq-init
-  [theSeq]
-  [[] theSeq])
+(defn- -init [theSeq] [[] theSeq])
 
 ; ISeq
-(defn- LazyMapSeq-first
+(defn- -first
   [this]
-  (let [first-val (first (. this theSeq))]
-    (new LazyMapEntry (key first-val) (val first-val))))
+  (let [first-val (first (.theSeq this))]
+    (new de.kotka.lazymap.LazyMapEntry (key first-val) (val first-val))))
 
-(defn- LazyMapSeq-rest
+(defn- -rest
   [this]
-  (when-let inner-rest (rest (. this theSeq))
-    (new LazyMapSeq inner-rest)))
+  (when-let [inner-rest (rest (.theSeq this))]
+    (new de.kotka.lazymap.LazyMapSeq inner-rest)))
 
-(defn- LazyMapSeq-cons
+(defn- -cons
   [this other]
   (new Cons other this))
 
 ; IPersistentCollection
-(defn- LazyMapSeq-count
+(defn- -count
   [this]
-  (.. this theSeq (count)))
+  (-> this .theSeq count))
 
-(defvar- LazyMapSeq-seq identity)
+(def #^{:private true} -seq identity)
 
-(defn- LazyMapSeq-empty
-  [_]
-  nil)
+(defn- -empty [_] nil)

src/de/kotka/lazymap/LazyMapSeq.gen.clj

-;-
-; Copyright 2008 (c) Meikel Brandmeyer.
-; All rights reserved.
-;
-; Permission is hereby granted, free of charge, to any person obtaining a copy
-; of this software and associated documentation files (the "Software"), to deal
-; in the Software without restriction, including without limitation the rights
-; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-; copies of the Software, and to permit persons to whom the Software is
-; furnished to do so, subject to the following conditions:
-;
-; The above copyright notice and this permission notice shall be included in
-; all copies or substantial portions of the Software.
-;
-; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-; THE SOFTWARE.
-
-(gen-and-save-class *builddir* 'de.kotka.lazymap.LazyMapSeq
-  :init         'init
-  :state        'theSeq
-  :implements   [clojure.lang.ISeq clojure.lang.Sequential]
-  :constructors {[clojure.lang.ISeq] []})

src/de/kotka/lazymap/lazymap.clj

-;-
-; Copyright 2008 (c) Meikel Brandmeyer.
-; All rights reserved.
-;
-; Permission is hereby granted, free of charge, to any person obtaining a copy
-; of this software and associated documentation files (the "Software"), to deal
-; in the Software without restriction, including without limitation the rights
-; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-; copies of the Software, and to permit persons to whom the Software is
-; furnished to do so, subject to the following conditions:
-;
-; The above copyright notice and this permission notice shall be included in
-; all copies or substantial portions of the Software.
-;
-; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-; THE SOFTWARE.
-
-(clojure/ns de.kotka.lazymap
-  (:refer-clojure)
-  (:import (de.kotka.lazymap LazyMapClass)))
-
-(defn- quote-values
-  [kvs]
-  (map (fn [[k# v#]] [k# `(delay ~v#)]) (partition 2 kvs)))
-
-(defn- make-map
-  [t kvs]
-  `(new LazyMapClass (apply ~t (concat ~@(quote-values kvs)))))
-
-(defmacro lazy-assoc
-  "<lazy-assoc> associates new values to the given keys in the given lazy map.
-  The values are not evaluated, before their first retrieval. They are
-  evaluated at most once."
-  [m & kvs]
-  `(reduce (fn [m# [k# v#]]
-             (. m# ~'lazyAssoc k# v#))
-           ~m (list ~@(quote-values kvs))))
-
-(defmacro lazy-hash-map
-  "<lazy-hash-map> creates a map. The values are not evaluated before their
-  first retrieval. Each value is evaluated at most once. The underlying map
-  is a hash map."
-  [& kvs]
-  (make-map `hash-map kvs))
-
-(defmacro lazy-sorted-map
-  "<lazy-sorted-map> creates a map. The values are not evaluated before their
-  first retrieval. Each value is evaluated at most once. The underlying map
-  is a sorted map."
-  [& kvs]
-  (make-map `sorted-map kvs))
-
-(defmacro lazy-struct-map
-  "<lazy-struct-map> creates a map. The values are not evaluated before their
-  first retrieval. Each value is evaluated at most once. The underlying map
-  is a struct map according to the provided structure s."
-  [s & kvs]
-  (make-map `(fn [& kvs#] (apply struct-map ~s kvs#)) kvs))
-
-(defmacro lazy-struct
-  "<lazy-struct> creates a map. The values are not evaluated before their
-  first retrieval. Each value is evaluated at most once. The underlying map
-  is a struct map according to the provided structure s. As with Clojure's
-  <struct> the values have to appear in the order of the keys in the structure."
-  [s & vs]
-  (let [vs (map (fn [v] `(delay ~v)) vs)]
-    `(new LazyMapClass (struct ~s ~@vs))))
 ; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 ; THE SOFTWARE.
 
-(clojure/ns de.kotka.lazymap.test
-  (:require [de.kotka.tap :as tap])
-  (:import  (de.kotka.lazymap LazyMapEntry)))
+(clojure.core/ns de.kotka.lazymap.test
+  (:require
+     [de.kotka.tap :as tap])
+  (:import
+     (de.kotka.lazymap LazyMapEntry)))
 
 (tap/plan 5)