1

I have been reading up alot about Arc and it seems to provide some good thing. Since Arc is a lisp and Clojure is a Lisp I was wondering if Arc could be implemented on top of Clojure?

Johannes Rudolph
  • 35,298
  • 14
  • 114
  • 172
yazz.com
  • 57,320
  • 66
  • 234
  • 385

2 Answers2

1

Most important issue that I can see immediately; Arc has real tail-call optimization, and clojure doesn't because of JVM limitations. AFAIK, this means you have to give up at least being able to call Arc functions directly as JVM methods, and also that you can't do a direct mapping of Arc functions to Clojure functions, which will probably mean you lose some performance.

Probably means you won't be able to easily create a compiled/efficient version of Arc using plain clojure. A "toy" interpreter on the other hand shouldn't be too hard if you know what you're doing.

Joost Diepenmaat
  • 17,633
  • 3
  • 44
  • 53
  • 2
    There is nothing preventing an Arc implementation in Clojure from automatically eliminating tail-recursive calls in the same way that recur works. Likewise, a similar automatic conversion can target a trampoline in the general case. – fogus Apr 21 '11 at 17:04
  • 2
    Yes, but as far as I understand the issue, you'd have to "trampoline" every tail call that isn't self-recursive to give the same guarantees that Arc does. Meaning you'd have to use continuation passing everywhere. That can of course be done, but there's a reason clojure doesn't use it. – Joost Diepenmaat Apr 21 '11 at 17:13
1

it souds like great fun to implament an Arc compiler in Clojure, though making it compile to JVM bytecode may be a bit more diffacult because of the TCO problems discussed above. Just because it's written in Clojure does not mean it needs to target the JVM.

On the other hand, an Arc interpreter would be very reasonable.

Arthur Ulfeldt
  • 90,827
  • 27
  • 201
  • 284