Arc Forumnew | comments | leaders | submitlogin
Rainbow Update: anarki, java interface, and a little editor
14 points by conanite 5998 days ago | 6 comments
rainbow now supports anarki's 'defcall and thread-local, and also supports calling java from arc. Rainbow's "java.arc" relies on 'defcall and so requires anarki. The built-in java support does not otherwise depend on anarki.

rainbow ships with a primitive text editor written in 41 lines of arc (not including the "swing.arc" library). Still being a lisp n00b, I'm sure this could be reduced a lot, but I already find writing gui code in arc is a lot more pleasant than writing it in java. "swing" btw is the name of the java gui library. Warning: it really is primitive. There's no "find", for example.

The editor includes an "eval" button and a "ppr" button (using pprint.arc) as a bonus. The eval button is great for exploratory coding, if you don't like copy/pasting into the repl (I certainly don't but maybe I'm just lazy). In the spirit of what one supposedly does with dog food, I've been developing the editor in itself as much as possible.

The editor is called "welder" for want of a better pun. Suggestions for a new name are definitely welcome. It's not as pretty as emacs, yet, but given that it's written in the hundred-year language, I'm sure it will catch up quickly ...

rainbow no longer includes the original arc; instead it installs itself in your arc directory. "rainbow.jar" goes in the root, and some .arc files under "/lib/rainbow". If this causes problems for git commits, let me know a better way. Install thus:

  ant -Darc_home=/path/to/anarki install
Run thus:

  cd /path/to/anarki
  java -jar rainbow.jar -e '(welder)'
You can specify a file to load at startup, for example:

  java -jar rainbow.jar -e '(welder "lib/rainbow/welder.arc")'
get rainbow here:

  git clone git://github.com/conanite/rainbow.git
enjoy ...


1 point by almkglor 5998 days ago | link

Regarding tagged types:

  arc> (= b (annotate 'bobo 23))
  #3(tagged bobo 23)
  arc> (* b 3)
  Error: "*: expects type <number> as 1st argument, given: #3(tagged bobo 23); other arguments were: 3"
  arc> (* (rep b) 3)
  69
Above is Anarki, not sure about Arc2.

I'm surprised at the shortness of welder.

As an aside, I'm somewhat uncomfortable with f!show as being equivalent to f.show(), since to me ! == structure access. Still, it's perfectly valid Arc.

-----

3 points by conanite 5997 days ago | link

I'm missing something in your comment about tagged types - is rainbow doing it wrong? Arc internally uses a vector to represent tagged types afaik, but rainbow uses a custom "Tagged" class. The example you give behaves in the same way in rainbow.

> I'm surprised at the shortness of welder.

It might be cheating to use java's ui libraries - most of the hard stuff is really in there. But at least now there's a way to call all that library goodness right from arc. I'd like to abstract away everything that looks like java so that theoretically, and if we really had nothing better to do, the same arc ui library could be implemented in any other host language providing a ui.

> I'm somewhat uncomfortable with f!show as being equivalent to f.show()

I set up 'defcall so that for a java-object 'thing,

  (thing 'method arg1 argn)
is equivalent to the java call

  thing.method(arg1, argn);
It seemed the natural thing to do, but it's only the first version ...

-----

1 point by almkglor 5997 days ago | link

> I'm missing something in your comment about tagged types - is rainbow doing it wrong? Arc internally uses a vector to represent tagged types afaik, but rainbow uses a custom "Tagged" class. The example you give behaves in the same way in rainbow.

No, I just got confused with the lack of 'rep in the call* test ^^ Sorry!

(thing!method arg1 argn) feels more natural to me, but I don't have any idea of any potential mismatch in the way java and arc works.

-----

2 points by conanite 5997 days ago | link

oops, no, I'm sorry. I didn't see what you were missing. The test is set up at the start of the test file, with

  (sref call* (fn (the-bobo size) (* the-bobo size)) 'bobo)
So

  (* b 3)
works where b is a 'bobo.

As for

  (thing!method arg1 argn)
it's true, when you write it that way, it feels more natural. At a first glance though, this means (thing 'method) must return a method-invoker, which then gets invoked with zero or more arguments. It seems like this would add complexity - instead of calling the method, we call to get the invoker and then call it. The question, as always, is whether the increase in readability merits the increase in complexity ... we'll see what happens I suppose.

-----

1 point by raymyers 5998 days ago | link

I get a stack overflow when running welder in Java 6. I can send the stack trace if need be.

Works fine in Sun's Java 5 though. Great work!

-----

4 points by conanite 5997 days ago | link

> I get a stack overflow when running welder in Java 6

Oh dear. I haven't installed java 6 yet. Please do send the stack trace anyway, maybe I can figure out what's going on.

> Works fine in Sun's Java 5 though. Great work!

Thank you!

-----