So if I have ATS running with libgc, a char* allocated with libc in 
embedded into ATS C code and then I cast char* to string: 
$UN.cast{string}(ptr) . I still have a string that is located in not 
garbage collected heap, so i have to free it explicitly, correct ? Same 
with strptr but ATS compiler backs me up and ensures that I free it .

суббота, 7 октября 2017 г., 15:58:08 UTC+3 пользователь gmhwxi написал:
>
>
> What I was trying to say is that malloc/free is external to ATS;
> it is not baked into ATS.
>
> If you use libgc for malloc/free, you get GC from libgc. If you use,
> say, libc for malloc/free, then you don't have GC.
>
> On Saturday, October 7, 2017 at 8:48:53 AM UTC-4, Russoul wrote:
>>
>> Sorry, I'm a bit lost now ) Right, ATS has no GC. But it can generate C 
>> code that can be linked with libgc with D_ATS_GCATS, right ? Or I'm 
>> still missing something ?
>> суббота, 7 октября 2017 г., 15:04:09 UTC+3 пользователь gmhwxi написал:
>>>
>>>
>>> ATS has no GC.
>>>
>>> You can use libgc to do malloc/free needed in the C code generated
>>> from ATS source. In that way, you get GC from libgc.
>>>
>>> You can also do $UNSAFE.castvwtp0{Strptr1}(pointer) to get a linear 
>>> string.
>>> Then you need to explicitly free the linear string at some point in your 
>>> program
>>> (or cast it into a non-linear string).
>>>
>>>
>>> On Sat, Oct 7, 2017 at 7:56 AM, Russoul <[email protected]> wrote:
>>>
>>>> And how to correctly convert char* to string ? Just 
>>>> $UNSAFE.cast{string}(pointer) ? Will the original char* be GCed by ATS ?
>>>>
>>>> суббота, 7 октября 2017 г., 14:33:13 UTC+3 пользователь gmhwxi написал:
>>>>>
>>>>>
>>>>> Assuming that you are targeting C. I would suggest that you use 
>>>>> snprintf
>>>>> (plus $UNSAFE.cast).
>>>>>
>>>>> On Saturday, October 7, 2017 at 5:40:01 AM UTC-4, Russoul wrote:
>>>>>>
>>>>>> convert primitives (int,float,...) to string (or linear string). 
>>>>>> Convert native char* to string and reversed ?
>>>>>>
>>>>> -- 
>>>> 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 [email protected].
>>>> To post to this group, send email to [email protected].
>>>> 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/db92b4d8-58aa-4033-a446-d4f009c0215c%40googlegroups.com
>>>>  
>>>> <https://groups.google.com/d/msgid/ats-lang-users/db92b4d8-58aa-4033-a446-d4f009c0215c%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>>
>>>

-- 
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 [email protected].
To post to this group, send email to [email protected].
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/099f9297-ce38-428b-b359-3a7275e34425%40googlegroups.com.

Reply via email to