@@ -1098,16 +1098,24 @@ defaults to returning v."))
1098
1098
IPrintWithWriter
1099
1099
(-pr-writer [o writer _] (-write writer str)))
1100
1100
1101
+ (defn var?
1102
+ " Returns true if v is of type cljs.core.Var"
1103
+ [v]
1104
+ (instance? cljs.core.Var v))
1105
+
1101
1106
(defn symbol
1102
- " Returns a Symbol with the given namespace and name."
1107
+ " Returns a Symbol with the given namespace and name. Arity-1 works
1108
+ on strings, keywords, and vars."
1103
1109
([name]
1104
- (if (symbol? name)
1105
- name
1106
- (let [idx (.indexOf name " /" )]
1107
- (if (< idx 1 )
1108
- (symbol nil name)
1109
- (symbol (.substring name 0 idx)
1110
- (.substring name (inc idx) (. name -length)))))))
1110
+ (cond (symbol? name) name
1111
+ (string? name) (let [idx (.indexOf name " /" )]
1112
+ (if (< idx 1 )
1113
+ (symbol nil name)
1114
+ (symbol (.substring name 0 idx)
1115
+ (.substring name (inc idx) (. name -length)))))
1116
+ (var? name) (.-sym name)
1117
+ (keyword? name) (recur (.-fqn name))
1118
+ :else (throw (new js/Error " no conversion to symbol" ))))
1111
1119
([ns name]
1112
1120
(let [sym-str (if-not (nil? ns )
1113
1121
(str ns " /" name)
@@ -1182,11 +1190,6 @@ defaults to returning v."))
1182
1190
(-invoke [_ a b c d e f g h i j k l m n o p q r s t rest]
1183
1191
(apply (val ) a b c d e f g h i j k l m n o p q r s t rest)))
1184
1192
1185
- (defn var?
1186
- " Returns true if v is of type cljs.core.Var"
1187
- [v]
1188
- (instance? cljs.core.Var v))
1189
-
1190
1193
; ;;;;;;;;;;;;;;;;;; fundamentals ;;;;;;;;;;;;;;;
1191
1194
1192
1195
(declare array-seq prim-seq IndexedSeq )
0 commit comments