Permalink
Browse files

Merge pull request #9 from amalloy/master

More portable/reliable implementation; no feature changes
  • Loading branch information...
2 parents 6851082 + c0a45c2 commit 491d5a02f883059b8a0a7c0c904d72444075811f @technomancy committed Jul 15, 2012
Showing with 7 additions and 7 deletions.
  1. +7 −7 src/serializable/fn.clj
View
14 src/serializable/fn.clj
@@ -3,15 +3,15 @@
(:refer-clojure :exclude [fn])
(:import java.io.Writer))
-(defn- save-env [bindings form]
+(defn- save-env [locals form]
(let [form (with-meta (cons `fn (rest form)) ; serializable/fn, not core/fn
(meta form))
quoted-form `(quote ~form)]
- (if bindings
- `(list `let ~(vec (apply concat (for [b bindings
- :let [sym (.sym b)]]
- [`(quote ~sym)
- `(list `quote ~sym)])))
+ (if locals
+ `(list `let [~@(for [local locals,
+ let-arg [`(quote ~local)
+ `(list `quote ~local)]]
+ let-arg)]
~quoted-form)
quoted-form)))
@@ -20,7 +20,7 @@
fn [& sigs]
`(with-meta (clojure.core/fn ~@sigs)
{:type ::serializable-fn
- ::source ~(save-env (vals &env) &form)}))
+ ::source ~(save-env (keys &env) &form)}))
(defmethod print-method ::serializable-fn [o ^Writer w]
(print-method (::source (meta o)) w))

0 comments on commit 491d5a0

Please sign in to comment.