Uses the Clojure compiler to analyze the given s-expr. Returns a map with keys :class and :primitive? indicating what the compiler concluded about the return value of the expression. Returns nil if not type info can be determined at compile-time. Example: (expression-info '(+ (int 5) (float 10))) Returns: {:class float, :primitive? true}
; clojure/contrib/repl_utils.clj:162 (defn expression-info [expr] (let [fn-ast (Compiler/analyze Compiler$C/EXPRESSION `(fn [] ~expr)) expr-ast (.body (first (.methods fn-ast)))] (when (.hasJavaClass expr-ast) {:class (.getJavaClass expr-ast) :primitive? (.isPrimitive (.getJavaClass expr-ast))})))
Copyright (c) Rich Hickey. All rights reserved.
The use and distribution terms for this software are covered by the Eclipse Public License 1.0, which can be found in the file epl-v10.html at the root of this distribution. By using this software in any fashion, you are agreeing to be bound by the terms of this license. You must not remove this notice, or any other, from this software.