Hacker News new | past | comments | ask | show | jobs | submit login

rainbow converts arc lists and hashes to and from java List and Map equivalents.

rainbow also uses 'defcall from anarki so you don't ever have to call java-invoke: you can put your java-object in functional position, followed by the method name, followed by the arguments. For example,

  (my-object 'hashCode)
is the equivalent of java's myObject.hashCode(); ... essentially the same number of tokens. I expect to wrap the most popular java libraries behind arc-sounding macros/functions.

rainbow comes with a tetris and a simple arc editor called welder, they both use java's Swing library, take a look if you'd like to see an example of this kind of wrapping. Or try http://www.fnargs.com/2009/01/calling-java-from-arc.html

I think "official arc" still assumes a unix for some functions ... I don't know what PG's final position on this is.




Apologies for the days of delay - I'm on a reduced HN diet.

So, in Clojure you can't use Java objects with the great sequence and hashmap libs:

(def h (new java.util.HashMap))

(. h put :a 1)

(. h put :b 2)

user=> h

#=(java.util.HashMap. {:b 2, :a 1})

Hashmaps in Clojure are, like Arc's, callable:

user=> ({:a 1 :b 2} :b)

2

But not if they are Java Maps:

user=> (h :b)

java.lang.ClassCastException: java.util.HashMap (NO_SOURCE_FILE:0)

So rainbow does the right thing - let's you use Arc functions on Java objects?

By the way, Clojure's .. macro is pretty handy:

(.. System (getProperties) (get "os.name")) expands to:

(. (. System (getProperties)) (get "os.name"))




Consider applying for YC's first-ever Fall batch! Applications are open till Aug 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: