Incidentally, 'lset is very, very hard to implement if closures are not very mutable, as in the arc2c output.
> and then make the reference through which you modified it point instead to this new object.
(def hmm (x)
(let y (cdr x)
(scar y 42))) ; is x mutated? the reference I used here was *just* y...
> the Arc copy function becomes essentially (...)
Yes, this is true, although I'd prefer to add some sort of 'uniq tag so that other pending messages don't accidentally get taken ('<== does pattern matchimg, obviously implemented via my p-m macro) ^^. It will even correctly handle recursive and shared structure, which I think the current 'copy does not ^^.
(def copy (arg)
(w/uniq tag
(==> (mypid) (list tag arg))
(<==
(,tag cpy) cpy)))
Edit:
> That's a good point. But what about having copy-on-write-if-more-than-one-logical-copy semantics? Then every Arc object on the heap would have a shared flag. Then if you send an object to another thread, the object is shared, and it has its internal shared field set to true (or 1, if this is C).
The problem here is: what if the object to be sent is already shared and the receiver already has it? Say:
(def process-A ()
(let v (list 42)
(==> B v)
(==> C v)))
(def process-B ()
(<==
any (==> C any)))
(def process-C ()
(givens v1 (<== any any)
v2 (<== any any)
(if (is v1 v2)
(err "I somehow received the same object twice!"))))