Arc Forumnew | comments | leaders | submitlogin
Arcc: arc compiler in arc (self-hosting)
19 points by rntz 5462 days ago | 5 comments
arcc is an arc-to-mzscheme compiler, which is written in arc3.1 (as distributed by pg) and which should be completely compatible with pg's arc. It is available as a branch on anarki:

  ~$ git clone git://github.com/nex3/arc.git -b arcc
  ~$ cd arc
It is also available as a tarball, to be unpacked into the arc directory:

  ~$ cd arc3.1
  ~/arc3.1$ wget http://www.rntz.net/files/arcc.tar.gz
  ~/arc3.1$ tar xzf arcc.tar.gz
All arcc-specific files are in a directory called arcc. To run arcc, first you have to use pg's arc compiler to compile arc.arc and arcc/ac.arc. I've provided an mzscheme script for doing this, arcc/boot.scm:

  # I here assume you have plt 4. The command-line arguments will 
  # differ slightly if you use mzscheme v372.
  ~/arc$ mzscheme --script arcc/boot.scm
This compiles arc.arc to arc.arc.scm and arcc/ac.arc to arcc/ac.arc.scm. Once you have these files, you can use arcc/run.scm to run an arcc REPL.

  ~/arc$ rlwrap mzscheme --no-init-file --repl --load arcc/run.scm
  Welcome to MzScheme v4.2.2 [3m], Copyright (c) 2004-2009 PLT Scheme Inc.
  Use (quit) to quit, (_tl) to return here after an interrupt.
  arc> (ac '(+ 2 3))
  (ar-funcall2 _+ 2 3)
  arc> 
That's pretty much all there is to it. To compile arcc using itself (bootstrapping proper), you can run the arc script arcc/reboot.arc. Since pg's arc3.1 and arcc should be compatible, this is unnecessary; but it does show that arcc can be self-hosting.

arcc is a fairly straightforward translation of pg & rtm's ac.scm and is, as I said, intended to be fully compatible with pg's arc; it does not support any anarki extensions. It can compile and load arc.arc, all the files in libs.arc, and itself; and running (asv) produces the desired hello world page. I have not tested it with the arc news server, and I would be pleased to hear of any bugs or incompatibilities.

As a self-hosting arc compiler, arcc is a fairly obvious starting point for extending and fiddling with the arc compiler itself. Redefining any of the functions used in arcc/ac.arc (most of which are prefixed with ac-) will change the way the compiler behaves when compiling future expressions. As a simple example, it is trivially easy to break the REPL:

  ~/arc$ mzscheme --no-init-file --repl --load arcc/run.scm
  Welcome to MzScheme v4.2.2 [3m], Copyright (c) 2004-2009 PLT Scheme Inc.
  Use (quit) to quit, (_tl) to return here after an interrupt.
  arc> (def ac x `'nil)
  *** redefining ac
  #<procedure: ac>
  arc> 2
  nil
  arc> (def foo (x) x)
  nil
  arc> (fn)
  nil


2 points by aw 5440 days ago | link

First time I've had a chance to look at this as I've been traveling -- wow -- very cool!

I was wondering if you would consider publishing this with a version number... such as this release might be 3.1-0, and then if you fix a bug or make an update the next version might be 3.1-1, and then if an Arc 3.2 comes out and you port that your version might be 3.2-0, etc.

You can do this in git simply by tagging your branch (e.g. tag arcc3.1-0 or whatever) and then I can pull the source by tag, and/or you could publish your tar file with a name like arcc3.1-0.tar.gz

The version numbering scheme doesn't matter to me; what I'm looking for is a way to say "my hack here works with rntz's arcc version X", and to be to distinguish that from some earlier or later version of your port.

Thanks!

-----

1 point by rntz 5425 days ago | link

Sad to say, I'm not planning on maintaining this at all. I simply don't have the time now that I'm back at school, and my interest in Arc has been waning for some time now. If I did plan on maintaining it, I'd certainly give some thought to version numbering.

-----

1 point by aw 5425 days ago | link

OK, I'll just refer to a particular version by its git commit id such as "601d219618c189554417082517066491e1386f35" :-)

-----

1 point by shader 5405 days ago | link

It's standard to refer to a git commit id by only the first few digits of the number.

So don't worry! You can call it merely "601d2" instead ;)

-----

1 point by adm 5460 days ago | link

a clickable link of source : http://github.com/nex3/arc/tree/arcc

-----