I know this is not identical but checkout this example,
https://github.com/githwxi/atslangweb/blob/master/ats2-lang/doc/EXAMPLE/INTRO/sieve_llazy.dats#L53
The tilde tells the compiler to free the empty stream in this example.
Is this similar to what you have in mind?
exception MyException of (list_vt(int))
fun test(l : list_vt(int)): void =
$raise MyException(l)
implement main0(argc,argv) =
test(list0_vt_cons(1,list0_vt_nil()))
exit(ATS): uncaught exception at run-time:
==465== Memcheck, a memory error detector
==465== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==465== Using Valgrind-3.14.0 and LibVEX; rerun with -h for copyright info
==465== Command: ./test
==465==
exit(ATS): uncaught exception at run-time:
test.dats:MyException(1024)
==465==
==465== HEAP SUMMARY:
==465== in use at exit: 40 bytes in 2 blocks
==465== total heap usage: 2 allocs, 0 frees, 40 bytes allocated
==465==
==465== LEAK SUMMARY:
==465== definitely lost: 24 bytes in 1 blocks
==465== indirectly lost: 0 bytes in 0 blocks
==465== possibly lost: 0 bytes in 0 blocks
==465== still reachable: 16 bytes in 1 blocks
==465== suppressed: 0 bytes in 0 blocks
==465== Rerun with --leak-check=full to see details of leaked memory
==465==
==465== For counts of detected and suppressed errors, rerun with: -v
==465== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
--
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.
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/6ba9272d-424a-431f-b33e-482483653b23%40googlegroups.com.
exception MyException of (list_vt(int))
fun test(l : list_vt(int)): void =
$raise MyException(l)
implement main0(argc,argv) =
try
test(list0_vt_cons(1,list0_vt_nil()))
with
~MyException(l) => free l
--
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.
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/366889e9-e88b-471f-8237-92b3c86923d4%40googlegroups.com.
When the linear resource is not freed before calling 'exit', unhandled exceptions, and unsafe casts.
From what I understand exit is akin to a backdoor. It inherits the return value of an expression. In other words, exit can be any type. I assume that unhandled exceptions are treated similarly.
%{
#include <alloca.h>
%}
#include "share/HATS/temptory_staload_bucs320.hats"
exception MyException of (list_vt(int))
fun test(l : list_vt(int)): void =
$raise MyException(l)
implement main0(argc,argv) =
try
test(list0_vt_cons(1,list0_vt_nil()))
with
~MyException(l) => free l