Linear lazy-evaluation in ATS2

40 views
Skip to first unread message

gmhwxi

unread,
Sep 28, 2013, 11:31:10 PM9/28/13
to ats-lan...@googlegroups.com
FYI.

Linear lazy-evaluation is now supported in ATS2. Here is an implementation
of Erathosthene's sieve of primes based on linear lazy-evalutation:

https://github.com/githwxi/ATS-Postiats/blob/master/doc/EXAMPLE/INTRO/sieve_llazy.dats

Every piece of allocated memory is freed at the end in this implementation. In terms of efficiency,
it takes less than 1/4 of the time taken by a corresponding implementation based on non-linear lazy
evaluation to find the 10000th prime number.

Cheers!

Zhiqiang Ren

unread,
Sep 29, 2013, 4:38:36 PM9/29/13
to ats-lan...@googlegroups.com
What does ~ns stand for in the following?

=====================================
and sieve (ns: stream_vt N2): stream_vt (N2) = $ldelay (sieve_con ns, ~ns)
=====================================

Brandon Barker

unread,
Sep 29, 2013, 4:43:15 PM9/29/13
to Zhiqiang Ren, ats-lan...@googlegroups.com
I believe you would say this is a linear notation specifying that $ldelay should free ns.

Brandon Barker
brandon...@gmail.com


--
You received this message because you are subscribed to the Google Groups "ats-lang-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ats-lang-user...@googlegroups.com.
To post to this group, send email to ats-lan...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/027d3366-a076-4173-8cac-49eb973b83af%40googlegroups.com.

gmhwxi

unread,
Sep 29, 2013, 5:51:59 PM9/29/13
to ats-lan...@googlegroups.com, Zhiqiang Ren
Right. This makes sure that resources contained in a linear lazy-value can be freed.

See:

https://sourceforge.net/p/ats2-lang/code/ci/master/tree/prelude/SATS/lazy_vt.sats?force=True

The function for freeing a lazy-value is declared as follows:


fun
lazy_vt_free
{a:vt0p}
(lazyval: lazy_vt (a)):<!wrt> void = "mac#atspre_lazy_vt_free"
overload
~ with lazy_vt_free

Reply all
Reply to author
Forward
0 new messages