Do closures of in general:
- Gen code with a malloc call?
- Gen code with free after exiting scope?
Meaning, if I am not linking a library with malloc and free I can't accidentally use it, and if I do have a library, I can't accidentally produce a leak?
For example, the function example sqrmodsum in the text: does it produce an error when malloc is not available, and if available, does this example leak? Or does it make one heap object that is reused on each call?
I guess I want to know under what circumstances a nieve maintainer can get into trouble. My hope is the behavior is either fail to compile, or no leak. If I am correct, then in which ways can I create a closure that leaks so I can r cognizant them?
Meaning, if I am not linking a library with malloc and free I can't accidentally use it, and if I do have a library, I can't accidentally produce a leak?
To recognize whether the C code generated from ATS source
does something bad (e.g., leaks memory), one needs to analyze the
C code. Tools need to be developed for doing such analysis.
--
You received this message because you are subscribed to a topic in the Google Groups "ats-lang-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ats-lang-users/zht_Kex7y-0/unsubscribe.
To unsubscribe from this group and all its topics, 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/eba42b74-d4a6-4d89-987d-a244dbccd36a%40googlegroups.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.
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/EEAA785F-0807-48A8-8126-18A012B9CBDA%40gmail.com.
the following error message issued by the linker:If you use malloc but do not use -DATS_MEMALLOC_????, then you will seepatscc -DATS_MEMALLOC_GCBDW -o foo foo.dats -lgc // using Bohem GCpatscc -DATS_MEMALLOC_LIBC -o foo foo.dats // using malloc/free in libcTo use malloc, you need to compile with a flag looking like -DATS_MEMALLOC_????For instance,
undefined reference to `atsruntime_malloc_undef'If you can compile your ATS code to executable without using -DATS_MEMALLOC_????,then your ATS code cannot generate memory leaks (because it does not even call malloc).
On Tue, Dec 29, 2015 at 9:56 AM, Mike jones <proc...> wrote:
I assume that if there is no alloc/malloc library to link, there cannot be links, because I kind of remember that for ATS the GC operates via this API. I would like to confirm that.The danger for me is my application layers on ThreadX, wrappers by Cypress, but I think it exposes the alloc/malloc. Would a simple search of the generated C be enough to determine no leaks? Or are there other calls I need to check?
Sent from my iPad
On Dec 28, 2015, at 5:30 PM, gmhwxi <gm...> wrote:
To recognize whether the C code generated from ATS source
does something bad (e.g., leaks memory), one needs to analyze the
C code. Tools need to be developed for doing such analysis.
On Monday, December 28, 2015 at 7:28:14 PM UTC-5, gmhwxi wrote:
In general, malloc needs to be called to construct a closure.
However, 'free' is *not* called automatically. If you use a linear
closure (cloptr) but do not call 'free', you will get a type-error somewhere.
If you use a persistent closure (cloref), you can not free the closure explicitly
(in a type-safe manner). Instead, GC is needed to reclaim the closure.
In other words, if you create a cloref but do not run GC, you have a potential
memory leak.
On Monday, December 28, 2015 at 5:13:53 PM UTC-5, Mike Jones wrote:Ref 3.13 of Introduction, ifold2...Do closures of in general:
- Gen code with a malloc call?
- Gen code with free after exiting scope?Meaning, if I am not linking a library with malloc and free I can't accidentally use it, and if I do have a library, I can't accidentally produce a leak?
For example, the function example sqrmodsum in the text: does it produce an error when malloc is not available, and if available, does this example leak? Or does it make one heap object that is reused on each call?
I guess I want to know under what circumstances a nieve maintainer can get into trouble. My hope is the behavior is either fail to compile, or no leak. If I am correct, then in which ways can I create a closure that leaks so I can r cognizant them?
--
You received this message because you are subscribed to a topic in the Google Groups "ats-lang-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ats-lang-users/zht_Kex7y-0/unsubscribe.
To unsubscribe from this group and all its topics, 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/eba42b74-d4a6-4d89-987d-a244dbccd36a%40googlegroups.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-users+unsubscribe@googlegroups.com.
To post to this group, send email to ats-lang-users@googlegroups.com.
Since Bohem GC replaces alloc, does the ATS compiler really generate different code for GC or does it just add some GC initiallization code?
--
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/c14d350a-f275-4fa0-9eae-7586e59d850f%40googlegroups.com.
=<clo1> I assume overrides a default of <cloref1>
lam@ I'm not sure what @ means. Does it mean pass tuple, anything, is something non-transparent being made transparent?
Cast does not use {}, why not? Is the compiler figuring it out on its own? If so, should it be {ptr} if explicit?
Cast because by not being ref, it has to be converted to a ptr? Seem messy not to just create a closure as pointer in the first place, so that type checking does its job.
fun{}
sqrmodsum2
(n: int, d: int): int = let
//
var
fopr =
lam@(res: int, x: int): int =<clo1>
if x mod d = 0 then res + x * x else res
//
in
ifold2(10, $UNSAFE.cast(addr@fopr), 0)
end // end of [sqrmodsum2]
This shows how to put it on heap/GC, and stack, how do you put it in static memory? I assume you create a standard function or instantiated template. Then do you have to cast it?
--
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/9206989e-1eaa-46e4-927d-541b9b4df898%40googlegroups.com.
The fun definitions have <cloref1>, and do not follow the typical syntax of a value bound to a lam. So does this mean a closure is returned? Does it mean the fun is a closure? Is any thing on the heap? And what is the purpose of it in this example?
fun{
a:t@ype
} insertion_sort
(
A: arrszref (a)
, cmp: (a, a) -> int
) : void = let
val n = g0uint2int_size_int(A.size())
fun ins (x: a, i: int):<cloref1> void =
if i >= 0 then
(
if cmp (x, A[i]) < 0
then (A[i+1] := A[i]; ins (x, i-1)) else A[i+1] := x
// end of [if]
) else A[0] := x // end of [if]
// end of [ins]
fun loop (i: int):<cloref1> void =
if i < n then (ins (A[i], i-1); loop (i+1)) else ()
// end of [loop]
in
loop (1)
fun
ifold2_( n: int, f: &(int, int) -<clo1> int, ini: int) : int =
if n > 0 then f(ifold2_ (n-1, f, ini), n) else ini// end of [ifold2]
--
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/8d8cb85b-f530-4d07-9dec-a16e35c3fc19%40googlegroups.com.
call-by-reference.
On Tue, Dec 29, 2015 at 3:23 PM, Mike Jones <pro...> wrote:
What does the & mean?
--
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.
And can you pass a closure by value? That assumes a tuple copy. Not efficient, but curious.
'lam@' means to form a closure in a given memory space.
--
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/b50a3ae2-d7f1-4981-b40b-8cfded0be221%40googlegroups.com.
//
// HX-2015-12-31:
// this one need a cast:
//
fun{}
sqrmodsum
(n: int, d: int): int = let
//
var
fopr =
lam@(res: int, x: int): int =<clo1>
if x mod d = 0 then res + x * x else res
//
in
ifold2(10, $UNSAFE.cast(addr@fopr), 0)
end // end of [sqrmodsum]
//