Arc Forumnew | comments | leaders | submitlogin
Jarc 21 Released
1 point by jazzdev 4916 days ago | 3 comments
I've released Jarc 21 today which has:

1) A rainbow compatibility module

  Jarc> (use 'rainbow)
  t
  Jarc> (java-import "java.lang.Integer")
  #(tagged mac #<procedure>)
  Jarc> (= jint (Integer new 12))
  12
  Jarc> jint!doubleValue
  12.0
  Jarc> (java-static-field "java.lang.Integer" "MAX_VALUE")
  2147483647
  Jarc> (Integer parseInt "12")                         
  12
It also includes dynamic proxies so you can implement Java interfaces. Very cool Rainbow feature!

  (java-imports java (util TreeSet Comparator))
  #(tagged mac #<procedure>)
  Jarc> (= lists-by-len (TreeSet new (Comparator implement nil (obj compare
    (fn (o1 o2)
      (if (iso o1 o2) 0
	  (< (len o1) (len o2)) -1
	  1))))))
  #set( )
  Jarc> (lists-by-len 'add '())
  t
  Jarc> (lists-by-len 'add '(foo bar))
  t
  Jarc> (lists-by-len 'add '(baz))
  t
  Jarc> lists-by-len
  #set( nil (baz) (foo bar) )
2) Various bug fixes reported in the forum recently

  (utest "double catch" (catch:list:point ignored throw.nil) is nil)
  (utest "on-err in ccc" (catch:on-err [+ 1] (fn () throw.2)) is 2)
  (utest "readc eof" (w/instring i "" (readc i)) is nil)
  (utest "double annotate" (rep (annotate 'a (annotate 'a 12))) is 12)
  (utest "cons as table key" (type:car:keys:obj (a) 1) is 'cons)
  
  (utest "ds opt arg" (let ((o x 2)) nil x) is 2)
  (utest "ds opt arg nil" (let ((o x 2)) '(nil) x) is nil)
  (utest "ds opt 2nd arg" (let (a (o b 2)) '(1) b) is 2)
  (utest "ds opt arg eval'd" (let default 2 (let ((o x default)) nil x)) is 2)
  (utest "ds opt 2nd arg eval'd" (let default 2 (let (a (o b default)) '(1) b)) is 2)
And I implemented the optional 'append arg to outfile also.

The goal of the Rainbow compatibility is to support a library of code that uses Java API's that will run on both Rainbow and Jarc.



1 point by rocketnia 4916 days ago | link

The goal of the Rainbow compatibility is to support a library of code that uses Java API's that will run on both Rainbow and Jarc.

Like the one Lathe has. ^_- http://arclanguage.org/item?id=11887

I'll be sure to look at Jarc 21 eventually, but I'm sort of falling behind thanks to, well, getting a job. XD I'm behind on trying out Rainbow and Semi-Arc too, so this is one more for the to-do list. ^_^;

I definitely appreciate the dynamic proxy support though. I'll see how easy it is to incorporate that into Lathe's jvm.arc... sooner or later.

-----

1 point by jazzdev 4916 days ago | link

161 days ago you announced your jvm.arc? Interesting. Seems useful.

So Groovy allows dynamic classes, not just interfaces? I'd like to do that in Jarc also. But I don't see how to do it without generating byte code. Jarc now includes Jasmin (a JVM assembler) so generating byte code is pretty straight-forward.

Congrats on the job.

-----

1 point by rocketnia 4916 days ago | link

So Groovy allows dynamic classes, not just interfaces? I'd like to do that in Jarc also. But I don't see how to do it without generating byte code.

Right, making new classes that extend classes (besides java.lang.Object) at runtime seems to require generating byte code. From http://download.oracle.com/javase/6/docs/technotes/guides/sc...:

Sun's implementation of JDK 6 is co-bundled with the Mozilla Rhino based JavaScript script engine. (...)

Rhino's JavaAdapter has been removed. JavaAdapter is the feature by which a Java class can be extended by JavaScript and Java interfaces may be implemented by JavaScript. This feature also requires a class generation library. We have replaced Rhino's JavaAdapter with Sun's implementation of the JavaAdapter. In Sun implementation, only a single Java interface may be implemented by a JavaScript object.

In other words, the Rhino distributed with JDK 6 provides no JavaAdapter functionality the Proxy class can't already achieve....

Congrats on the job.

Thanks much! XD

-----