File tree 2 files changed +22
-15
lines changed
2 files changed +22
-15
lines changed Original file line number Diff line number Diff line change 3043
3043
(even? (count bindings)) " an even number of forms in binding vector" )
3044
3044
`(let* ~(destructure bindings) ~@body))
3045
3045
3046
+ (defn ^{:private true }
3047
+ maybe-destructured
3048
+ [params body]
3049
+ (if (every? symbol? params)
3050
+ (cons params body)
3051
+ (loop [params params
3052
+ new-params []
3053
+ lets []]
3054
+ (if params
3055
+ (if (symbol? (first params))
3056
+ (recur (next params) (conj new-params (first params)) lets)
3057
+ (let [gparam (gensym " p__" )]
3058
+ (recur (next params) (conj new-params gparam)
3059
+ (-> lets (conj (first params)) (conj gparam)))))
3060
+ `(~new-params
3061
+ (let ~lets
3062
+ ~@body))))))
3063
+
3046
3064
; redefine fn with destructuring and pre/post conditions
3047
3065
(defmacro fn
3048
3066
" (fn name? [params* ] exprs*)
3077
3095
(concat (map (fn* [c] `(assert ~c)) pre)
3078
3096
body)
3079
3097
body)]
3080
- (if (every? symbol? params)
3081
- (cons params body)
3082
- (loop [params params
3083
- new-params []
3084
- lets []]
3085
- (if params
3086
- (if (symbol? (first params))
3087
- (recur (next params) (conj new-params (first params)) lets)
3088
- (let [gparam (gensym " p__" )]
3089
- (recur (next params) (conj new-params gparam)
3090
- (-> lets (conj (first params)) (conj gparam)))))
3091
- `(~new-params
3092
- (let ~lets
3093
- ~@body)))))))
3098
+ (maybe-destructured params body)))
3094
3099
new-sigs (map psig sigs)]
3095
3100
(with-meta
3096
3101
(if name
Original file line number Diff line number Diff line change 50
50
set
51
51
(disj 'Object 'java.lang.Object)
52
52
vec)
53
- methods (apply concat (vals impls))]
53
+ methods (map (fn [[name params & body]]
54
+ (cons name (maybe-destructured params body)))
55
+ (apply concat (vals impls)))]
54
56
(when-let [bad-opts (seq (remove #{:no-print } (keys opts)))]
55
57
(throw (IllegalArgumentException. (apply print-str " Unsupported option(s) -" bad-opts))))
56
58
[interfaces methods opts]))
You can’t perform that action at this time.
0 commit comments