|From time to time I write a little bit of arc, run it on rainbow, and find it doesn't work, then spend a day fixing rainbow. Yesterday is was double-unquote in a nested quasiquote:|
which now returns what you'd expect:
arc> ((fn (z) `(x y z ,z `(x y z ,z ,,z))) 'foo)
I checked in a test for this on anarki. This problem arose when I was looking for a way to make java classes much more accessible - now you can write
(x y z foo `(x y z ,z ,foo))
which creates a macro called HashMap. You can use this macro to create new instances:
arc> (java-import "java.util.HashMap")
#<tagged mac ...
or to access static fields or methods on the class ...
arc> (HashMap new)
'java-import is a macro that generates a macro whose name is the name of the java class. Being a newbie, I'm sure this is the most unlispish way to do it. Any recommendations?
arc> (java-import "javax.imageio.ImageIO")
arc> (ImageIO write img format output) ; "write" is a static method on ImageIO; (img format output) are its params
[rainbow is an implementation of arc in java available at http://github.com/conanite/rainbow/tree/master ]
(mac java-import (class)
(let simple-name (last:tokens class #\.)
`(mac ,(sym simple-name) (method . args)
(if (is method 'new) `(java-new ,,class ,@args)
`(java-static-invoke ,,class ',method ,@args)))))