Arc Forumnew | comments | leaders | submitlogin
3 points by elibarzilay 5647 days ago | link | parent

First of all, updating to the recent plt version will be good, since there have been a lot of optimizations since then, including a lot of work to the compiler and the jitter.

Arc needs to do some list marshaling in any case to deal with nil -- and as such it reimplements nearly all of the list operations, deferring to mzscheme functions only for a few things. Because of this, using `mcons' shouldn't be too problematic (not even for speed, since arc functions in general are not careful about cyclic lists, a plain implementation will be fast enough -- for example, mzscheme's `map' is now implemented in scheme). I have done some tests in the past to measure

Probably the only major problem is how to deal with a rest argument. One option is to make it illegal to mutate rest arguments. Another is to hook on the fact that rest arguments are not modified often -- so instead of copying them to a mutable list on every call, they can be converted only when needed, by the functions that change the contents of these lists. Given the above (need to implement list functionality anyway), this wouldn't be difficult -- basically some wrapper around a mzscheme list that can do the necessary work. As a side benefit it can be used to deal with nil too, which will make that run faster as well.

(BTW, this will be much faster than using r6rs or r5rs modes.)



1 point by CatDancer 5647 days ago | link

One option is to make it illegal to mutate rest arguments.

Currently, in arc.arc, list is defined as

  (def list args args)
so this would need to change if rest arguments couldn't be mutated. (Which would be OK with me, I can't think of a single case where I ever mutated a rest argument).

Another is to hook on the fact that rest arguments are not modified often -- ... they can be converted only when needed

How could this possibly work??

  ((fn args
     (= (cadr args) 'X)
     args)
   'a 'b 'c)
sure, it would be easy for set-cdr! to see that the second pair is immutable and decide to create a new mutable cons. But args is still going to be pointing to the original list of immutable pairs!

As a side benefit it can be used to deal with nil too, which will make that run faster as well.

Can you explain? (I need smaller steps to be able to follow you :-)

(BTW, this will be much faster than using r6rs or r5rs modes.)

Yes, I was getting that impression browsing through the r6rs and r5rs code.

The way I'm leaning right now is to first rewrite the Arc compiler to generate PLT 4 code in the simplest possible way, for example to always convert rest arguments to mutable lists. Then, things like making rest arguments immutable could be done as an optimization if desired.

-----

1 point by elibarzilay 5646 days ago | link

For the "on-demand" conversion some PLT magic will be needed -- I'm basically talking about doing something at the level of the PLT function that is the result of compiling an arc function. In any case, explaining more through this medium will be hard for me...

-----

1 point by CatDancer 5646 days ago | link

Send me an email at cat@catdancer.ws, or use a pastebin and post the link here.

-----