Arc Forumnew | comments | leaders | submitlogin
(-- rainbow!defects)
3 points by conanite 3099 days ago | discuss
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:

  arc> ((fn (z) `(x y z ,z  `(x y z ,z ,,z))) 'foo)
which now returns what you'd expect:

  (x y z foo `(x y 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

  arc> (java-import "java.util.HashMap")
  #<tagged mac ...
which creates a macro called HashMap. You can use this macro to create new instances:

  arc> (HashMap new)
or to access static fields or methods on the class ...

  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
'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?

  (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)))))
[rainbow is an implementation of arc in java available at ]