awwx.ws

mpair0

Arc lists implemented with MzScheme’s mutable pairs

arc3.1-mpair0.tar

This is an experimental stab at implementing Arc lists with MzScheme mutable pairs (mpairs), instead of using pointers to mutate MzScheme’s pairs (which are normally immutable in PLT 4).

Only lightly tested, but it appears to fix the queue bug (http://arclanguage.org/item?id=11347), at least in my test with PLT Scheme 4.2.4.

Naturally if you try this and find any bugs, please do let me know.

It also runs the queue test (without output) about twice as fast as the original arc3.1, which surprised me. I had expected that this hack would be a bit slower, since it adds an additional runtime check for an mpair to the implementation of Arc’s car etc. But maybe the check in the original arc3.1 to see whether mzscheme supports set-car! and set-cdr! at runtime is especially slow.

This version, unlike arc3.1, doesn’t run on PLT 372. It requires PLT Scheme 4. (In PLT Scheme 3, pairs were mutable, so “mpairs” didn’t exist).

This hack builds upon rntz’s extraction of the Arc runtime into its own Scheme module ar.scm which he did for his port of the Arc compiler to Arc. (Someday I’d like to get this mpair hack working with his compiler port as well, but I haven’t taken the time to do that yet).

Another small change is that the Arc runtime uses PLT 4 functions instead of running in the PLT 3 compatibility mode.

A few caveats...

I hacked the Arc compiler so that argument lists with simple arguments and a rest argument correctly convert the rest argument into a mutable Arc list. Thus this works:

(def list args args)

but I lazily haven't fixed it to work to work with complex arguments yet, so in

(def foo ((a b) . rest) ...)

“rest” is still incorrectly an immutable list.

And while I hacked the Arc runtime to accept either immutable pairs or mutable mpair's, I could have easily missed a few places. (As I said I’ve only lightly tested this...) So consider this an “alpha” release, there may be bugs. But further testing would be helpful!

andrew.wilcox [at] gmail.com