diff options
author | Rich Hickey <richhickey@gmail.com> | 2008-11-26 23:13:57 +0000 |
---|---|---|
committer | Rich Hickey <richhickey@gmail.com> | 2008-11-26 23:13:57 +0000 |
commit | 4d944fea131f35d4bb88822127274d25bfcef100 (patch) | |
tree | cdb34e3516d7e3c081057c8152d25223b286022c | |
parent | 01ccd1be4ac8cc3e91d489ad3762ba878b3e5e59 (diff) |
tweaked docs
added while
-rw-r--r-- | src/clj/clojure/core.clj | 26 | ||||
-rw-r--r-- | src/clj/clojure/genclass.clj | 26 |
2 files changed, 36 insertions, 16 deletions
diff --git a/src/clj/clojure/core.clj b/src/clj/clojure/core.clj index 6b01837f..8da29d1c 100644 --- a/src/clj/clojure/core.clj +++ b/src/clj/clojure/core.clj @@ -3089,8 +3089,10 @@ respectively, except the arguments are unevaluated and need not be quoted, and the :gen-class clause does not take a name (since the class name corresponds to the ns name). If :refer-clojure is not - used, a default (refer 'clojure) is used. Use of ns is preferred to - individual calls to in-ns/require/use/import: + used, a default (refer 'clojure) is used. The :gen-class directive + is ignored when not compiling. If :gen-class is not specified, when + compiled the generated class will have only main. Use of ns is + preferred to individual calls to in-ns/require/use/import: (ns foo (:refer-clojure :exclude [ancestors printf]) @@ -3346,9 +3348,16 @@ (binding [*pending-paths* (conj *pending-paths* path)] (clojure.lang.RT/load (.substring path 1)))))) -(defn compile [lib] +(defn compile + "Compiles the namespace named by the symbol lib into a set of + classfiles. The source for the lib must be in a proper + classpath-relative directory. The output files will go into the + directory specified by *compile-path*, and that directory too must + be in the classpath." + [lib] (binding [*compile-files* true] - (load-one lib true true))) + (load-one lib true true)) + lib) ;;;;;;;;;;;;; nested associative ops ;;;;;;;;;;; @@ -3526,6 +3535,15 @@ (when ^name (.setMeta v ^name)) v))) +(defmacro while + "Repeatedly executes body while test expression is true. Presumes + some side-effect will cause test to become false/nil. Returns nil" + [test & body] + `(loop [] + (when ~test + ~@body + (recur)))) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; helper files ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/src/clj/clojure/genclass.clj b/src/clj/clojure/genclass.clj index e85f9a94..77567916 100644 --- a/src/clj/clojure/genclass.clj +++ b/src/clj/clojure/genclass.clj @@ -71,15 +71,18 @@ 'char Character/TYPE}) (defn gen-class - "Generates compiled bytecode for a class with the given - package-qualified cname (which, as all names in these parameters, can - be a string or symbol). The gen-class construct contains no + "This documents the :gen-class directive of the ns function, and is + not meant to be called directly. + + Generates compiled bytecode for a class with the given + package-qualified cname (which, as all names in these parameters, + can be a string or symbol). The gen-class construct contains no implementation, as the implementation will be dynamically sought by the generated class in functions in a corresponding Clojure namespace. Given a generated class org.mydomain.MyClass with a method named mymethod, gen-class will generate an implementation - that looks for a function named -mymethod in a Clojure - namespace called org.mydomain.MyClass . All inherited methods, generated + that looks for a function named -mymethod in a Clojure namespace + called org.mydomain.MyClass . All inherited methods, generated methods, and init and main functions (see :methods, :init, and :main below) will be found similarly. The static initializer for the generated class will attempt to load the Clojure support code for @@ -88,10 +91,10 @@ Note that methods with a maximum of 18 parameters are supported. - Returns a map containing :name and :bytecode. Most uses will be - satisfied by the higher-level gen-and-load-class and - gen-and-store-class functions, which generate and immediately load, - or generate and store to disk, respectively. + In all subsequent sections taking types, the primitive types can be + referred to by their Java names (int, float etc), and classes in the + java.lang package can be used without a package qualifier. All other + classes must be fully qualified. Options should be a set of key/value pairs, all of which are optional: @@ -118,8 +121,7 @@ parameter may be used to explicitly specify constructors, each entry providing a mapping from a constructor signature to a superclass constructor signature. When you supply this, you must supply an :init - specifier. In this and all subsequent sections taking types, the primitive - types can be referred to by their Java names (int, float etc) + specifier. :methods [ [name [param-types] return-type], ...] @@ -290,7 +292,7 @@ ;static fields for vars (doseq [v var-fields] - (. cv (visitField (+ (. Opcodes ACC_PUBLIC) (. Opcodes ACC_FINAL) (. Opcodes ACC_STATIC)) + (. cv (visitField (+ (. Opcodes ACC_PRIVATE) (. Opcodes ACC_FINAL) (. Opcodes ACC_STATIC)) (var-name v) (. var-type getDescriptor) nil nil))) |