Arc Forumnew | comments | leaders | submitlogin
1 point by rkts 6174 days ago | link | parent

Well, I was thinking par would be call-by-value. So your accumulator would have to be something like

  (def ref (x) (obj contents x))

  (def ++ref (x (o by 1)) (++ (x 'contents) by))

  (def accgen (n) (par ++ref (ref n)))
I don't know if a call-by-reference par could be implemented using macros. I also don't know that that's a good idea, since it could lead to bugs when mutation is involved.

  (= fns nil)

  (= x 1)
  (push (par + x) fns)

  (= x 2)
  (push (par + x) fns)

  (= x 3)
  (push (par + x) fns)

  (map [_ 1] fns) => (4 4 4)  ; probably not what you want
Edit: I think the issue is that we have slightly different definitions of partial application. You are thinking of it as a sort of syntactic sugar on top of closures, whereas I (being primarily an ML programmer) am used to thinking of partial application as a function call. So that's why we have different intuitions about how it should work.