For the field 'f', you can provide a getref function (instead of a get 
function),
which returns the pointer to the field (instead of the content of the 
field).

>>I think this problem has its roots in ATS record/struct can't keep 
at-view for pointer member in themselves. Then we only need 
setter/getter for pointer member in the record/struct. Members without 
pointer should be accessed by normal method in ATS language. 

A record in ATS CAN keep the proof of an at-view inside a record. However,
doing so would complicate programming quite a lot; it may not be suitable
for translating C code into ATS.

On Saturday, September 3, 2016 at 4:45:13 AM UTC-4, Kiwamu Okabe wrote:
>
> Hi Hongwei, 
>
> On Thu, Sep 1, 2016 at 1:02 PM, gmhwxi <...> wrote: 
> > I think you need to try it on a realistic example in order to get a 
> sense 
> > as to how it works in practice. My suspicion is that the at-view style 
> may 
> > not be adequate for a "complex" struct. I would go with the aptr-style, 
> > which 
> > allows you to take advantage of the support for overloading in ATS. 
>
> I think I should firstly choose at-view-style, because it's good for a 
> struct has another struct as member. 
>
> Using aptr-style, the code having such struct is following: 
>
>
> https://github.com/jats-ug/practice-ats/tree/53cffb10c1f46603201fbff178e6c1a43eb20e85/mutual_struct3
>  
>
> https://github.com/jats-ug/practice-ats/blob/53cffb10c1f46603201fbff178e6c1a43eb20e85/mutual_struct3/main.dats#L43
>  
>
> Above code read whole struct member `f` in `struct bar` to read int 
> member `b` in `struct foo`. It can not access the member only. It 
> means needing much memory access. If using the other style of 
> setter/getter for struct in struct, this problem may be fixed. 
> However, It will drop coherence on getter/settter. 
>
> On the other side, using at-view-style, the code having such struct is 
> following: 
>
>
> https://github.com/jats-ug/practice-ats/tree/53cffb10c1f46603201fbff178e6c1a43eb20e85/mutual_struct2
>  
>
> https://github.com/jats-ug/practice-ats/blob/53cffb10c1f46603201fbff178e6c1a43eb20e85/mutual_struct2/main.dats#L31
>  
>
> Above code can directly read/write int member `b` in `struct foo` in 
> `struct bar`. 
>
> I think this problem has its roots in ATS record/struct can't keep 
> at-view for pointer member in themselves. Then we only need 
> setter/getter for pointer member in the record/struct. Members without 
> pointer should be accessed by normal method in ATS language. 
>
> Of course, if I know mistake on choosing at-view-style, I'll secondly 
> choose your aptr-style. 
>
> 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/fbc82c8b-e418-43bb-9e5a-23de324da60d%40googlegroups.com.

Reply via email to