Well, I do *not* think that translating a struct in C into ATS record
can bring more safety. I suggest the following strategy:

1. Translating each struct in C into an abstract type in ATS and generating
    a generic programming interface for this abstract type. For instance, 
the
    style involving aptr I showed is a reasonable way to get started.

2. For a particular C struct (say, inode). you can adapt/adjust the generic 
interface
    to make it better suited for capturing programming invariants. For 
instance, you
    may need to introduce abstract views to properly handle reference 
counting.

Given the complexity of the C code you are to re-write, it is only 
realistic to expect
that you need to make use of unsafe features. The objective here is to 
minimize the
use of such features.

---Hongwei



On Wednesday, August 31, 2016 at 7:07:22 AM UTC-4, Kiwamu Okabe wrote:
>
> Hi Hongwei, 
>
> On Wed, Aug 31, 2016 at 3:35 AM, gmhwxi<...> wrote: 
> > What kind of records do you have in mind? 
>
> Sorry for my poor explanation. I wrote following code using ATS record 
> and "at-view style": 
>
>
> https://github.com/jats-ug/practice-ats/blob/6f663912d6118899861889f4ef3b835d3ceb5774/mutual_record/main.dats
>  
>
> Above code has following unsafe points: 
>
> A. Create at-view from nothing. 
>   
> https://github.com/jats-ug/practice-ats/blob/6f663912d6118899861889f4ef3b835d3ceb5774/mutual_record/main.dats#L11
>  
> B. Assign raw pointer. 
>   
> https://github.com/jats-ug/practice-ats/blob/6f663912d6118899861889f4ef3b835d3ceb5774/mutual_record/main.dats#L25
>  
>
> I think these unsafe things is coming from that ATS record can't 
> maintain at-view in. 
>
> My motivation is re-writing C language code using ATS language, and 
> getting more safe code. I'll rewrite the C code little by little. 
> At first stage, the ATS code includes some structs from C code. 
> At second state, should I re-write the struct as ATS record? If 
> re-write, I'll get more safe design in ATS code? Or which choose 
> struct/record is not important thing? 
>
> Best regards, 
> -- 
> Kiwamu Okabe at METASEPI DESIGN 
>

-- 
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/c288888f-2992-4685-b19d-52b525923fc5%40googlegroups.com.

Reply via email to