Arc Forumnew | comments | leaders | submitlogin
Lazy evaluation in Arc
6 points by dido 6321 days ago | 3 comments
Does Arc have facilities for doing lazy evaluation/deferred computation? As far as I can tell, Arc doesn't use Scheme's delay or force anywhere, so I guess the answer is probably no. Are there plans of adding this sort of functionality to Arc? I don't think it would be particularly difficult.


8 points by absz 6321 days ago | link

On some level, the answer is "yes, of course."

  (mac delay body
    `(annotate 'promise (fn () ,@body)))
  
  (def force (promise)
    ((rep promise)))
This was lightly adapted from http://cadrlife.blogspot.com/2008/02/lazy-lists-in-arc.html which I found on this forum -- read it for a more complete version with various supporting functions, etc. It's not primitive lazy evaluation, but it should work for many of the same things that delay/force work for.

-----

1 point by cooldude127 6321 days ago | link

i knew i had seen it done for arc already. it was that article.

-----

1 point by cooldude127 6321 days ago | link

delay and force can be pretty easily written using memoized functions.

or it might be possible to steal scheme's. either way.

-----