Arc Forumnew | comments | leaders | submitlogin
2 points by almkglor 4144 days ago | link | parent

re: GC - I think you're not properly handling sharedvar's (but then I don't have much time to read it). Specifically I think you're not properly marking sharedvar's. Since your GC needs to know the structure, you might need to put type tags on sharedvar's after all.

re: primitives: I think it's better to split the primitives: %+ for numeric addition, %string+ for string addition. Then define in lib-ac.scm.arc:

  (set +
    (fn (a b)
      (if (and (is (type a) 'int) (is (type b) 'int))
          (%+ a b)
          (if (and (is (type a) 'string) (is (type b) 'string))
              (%string+ a b)
              (%err "+: type mismatch")))))
We can even define the above as $+ and define + as variadic, reducing the input using $+, as in canonical Arc.

1 point by sacado 4144 days ago | link

Yep, I did not try to handle sharedvars at all with my GC. I will eventuelly need to give them a type tag, but I deferred that to the next release :) Splitting polymorphic functions is something that has to be done too.

As for variadic +, I don't know : if we transform (+ a b c d) in (+ a (+ b (+ c d))) during the first phase of compilation, we obviously handle variadic +, but at the end (in the generated code), the ADD() primitives only handles + with 2 args, which I guess would be more efficient ? And, that way, we could translate (+ a 1 b 2) into (+ a (+ 3 b)), and (+) to 0, which will eventually have to be done.


3 points by almkglor 4143 days ago | link

Then someone redefines '+ so that it doesn't just add numbers or concatenate strings. Say (+ 1 2 "asdf") becomes "3asdf".

Further, what if we need to pass '+ as a function to another function?

  (def hmm (op)
    (op 1 2 3 4 5))


1 point by sacado 4143 days ago | link

Oh, yes, so that wasn't really a good idea...