[stream_vt_head_exn], strange behavior

20 views
Skip to first unread message

August Alm

unread,
Apr 19, 2017, 9:06:22 AM4/19/17
to ats-lang-users
Hi!

The following code compiles but segfaults when run:

         val from_vt_nine = from_vt(9)
         val nine = stream_vt_head_exn<int>(from_vt_nine)
         val () = println!(nine: int)

The follwing code, on the other hand, executes as expected:

         val from_vt_nine = from_vt(9)
         val- ~stream_vt_cons(nine, ns) = !from_vt_nine
         val () = println!(nine: int)

Both examples prefaced with

         #include "share/atspre_define.hats"
         #include "share/atspre_staload.hats"
        
         val from_vt = fix f(i: int): stream_vt(int) =>
           $ldelay( stream_vt_cons{int}(i, f(i+1))
                     , ~f(i) )

What's up with this?

Hongwei Xi

unread,
Apr 19, 2017, 9:56:42 AM4/19/17
to ats-lan...@googlegroups.com
The 'free' part of from_vt should be dropped:

val
from_vt =
fix f(i: int): stream_vt(int) =>
$ldelay(stream_vt_cons{int}(i, f(i+1)))

stream_vt_head_exn tries to free a given stream. In the above case,
freeing the given stream trigger infinite computation.

In the follow code, 'ns' is leaked:


val from_vt_nine = from_vt(9)
val- ~stream_vt_cons(nine, ns) = !from_vt_nine
val () = println!(nine: int)

--
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-users+unsubscribe@googlegroups.com.
To post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/25a52904-e4a2-464d-90d1-bda5f00797a9%40googlegroups.com.

August Alm

unread,
Apr 19, 2017, 10:10:29 AM4/19/17
to ats-lang-users
Thank you! Still learning how to handle laziness. =)
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.

gmhwxi

unread,
Apr 19, 2017, 1:53:55 PM4/19/17
to ats-lang-users
stream_vt is pretty similar to the linear hom you used.
Essentially, stream_vt is a linear hom whose arity equals 0.
Reply all
Reply to author
Forward
0 new messages