Problem with Code Dispatch for Anonymous Functions?

2013-03-10 Thread Devin Walters
Could anyone help me understand why the following code is breaking? 

(require '[clojure.pprint :refer [with-pprint-dispatch code-dispatch pprint]])
(with-pprint-dispatch code-dispatch (pprint (read-string (^:once fn* [x] x

IllegalArgumentException Don't know how to create ISeq from: 
clojure.lang.Symbol clojure.lang.RT.seqFrom (RT.java:505)
#(

The #( is not a typo. It starts to print and then fails. Looking at the code, 
it looks like there's an issue here:
(defn- pprint-anon-func [alis]
  (let [args (second alis)
nlis (first (rest (rest alis)))]
(if (vector? args)
  (binding [*symbol-map* (if (= 1 (count args)) 
   {(first args) %}
   (into {} 
 (map 
  #(vector %1 (str \% %2)) 
  args 
  (range 1 (inc (count args))]
((formatter-out ~#(~;~@{~w~^ ~_~}~;)~:) nlis))
  (pprint-simple-code-list alis



I squinted at it for a bit, but I'm not sure what's up. Anyone have any ideas?

Thanks,
-- 
'(Devin Walters)

-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Problem with Code Dispatch for Anonymous Functions?

2013-03-10 Thread Devin Walters
After discussing with a couple of folks in IRC (big thank you to hyPiRion for 
his help), I opened a ticket to address this bug here: 
http://dev.clojure.org/jira/browse/CLJ-1181 

Long story short, ((formatter-out ~#(~;~@{~w~^ ~_~}~;)~:) nlis) expects 
nlis to be a sequence, but in the case of (^:once fn* [x] x) it is a symbol.

Thanks,
-- 
'(Devin Walters)


On Sunday, March 10, 2013 at 3:36 PM, Devin Walters wrote:

 Could anyone help me understand why the following code is breaking? 
 
 (require '[clojure.pprint :refer [with-pprint-dispatch code-dispatch pprint]])
 (with-pprint-dispatch code-dispatch (pprint (read-string (^:once fn* [x] 
 x
 
 IllegalArgumentException Don't know how to create ISeq from: 
 clojure.lang.Symbol clojure.lang.RT.seqFrom (RT.java:505)
 #(
 
 The #( is not a typo. It starts to print and then fails. Looking at the 
 code, it looks like there's an issue here:
 (defn- pprint-anon-func [alis]
   (let [args (second alis)
 nlis (first (rest (rest alis)))]
 (if (vector? args)
   (binding [*symbol-map* (if (= 1 (count args)) 
{(first args) %}
(into {} 
  (map 
   #(vector %1 (str \% %2)) 
   args 
   (range 1 (inc (count args))]
 ((formatter-out ~#(~;~@{~w~^ ~_~}~;)~:) nlis))
   (pprint-simple-code-list alis
 
 
 
 I squinted at it for a bit, but I'm not sure what's up. Anyone have any ideas?
 
 Thanks,
 -- 
 '(Devin Walters)
 

-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.