I also tried a style involving linear pointers:

https://github.com/githwxi/ATS-Postiats-test/blob/master/contrib/hwxi/TEST30/struct1.dats

The type of a linear pointer is aptr(T, L), where T is the type of the 
content and L is the address.

With this style, there seems to be adequate safety checking. Of course. it 
needs to be put into
practice to see how it actually fares.

On Saturday, August 27, 2016 at 11:54:56 AM UTC-4, gmhwxi wrote:
>
> With this style, you do not really need the following types:
>
> absvtype struct_foo_ptr(l:addr) = ptr l
> absvtype struct_bar_ptr(l:addr) = ptr l
>
> If an at-view T@l for a pointer ptr(l) can be found, the system assumes
> that the pointer is not NULL. You may use a run-time check to solve this
> issue (or use optional views).
>
> My concern with this style is that it is still very verbose in practice.
> To get something closer to the C style, I think that having abstract types 
> like
> struct_foo_ptr and struct_bar_ptr is a better way to go.
>
> On Saturday, August 27, 2016 at 8:44:44 AM UTC-4, Kiwamu Okabe wrote:
>>
>> On Sat, Aug 27, 2016 at 8:38 PM, Kiwamu Okabe <...> wrote: 
>> > * Easily support double pointer struct member such like `struct foo 
>> **p;`. 
>>
>> I tried to write that as following: 
>>
>>
>> https://github.com/jats-ug/practice-ats/blob/a3cfedca36459d7fb5b26ddfbba62de237900902/mutual_struct2/gen.sats
>>  
>>
>> https://github.com/jats-ug/practice-ats/blob/a3cfedca36459d7fb5b26ddfbba62de237900902/mutual_struct2/main.dats
>>  
>>
>> However, I have a question. It can dereference pointer without 
>> checking that it doesn't equal NULL: 
>>
>>
>> https://github.com/jats-ug/practice-ats/blob/a3cfedca36459d7fb5b26ddfbba62de237900902/mutual_struct2/main.dats#L23
>>  
>>
>> ``` 
>> val () = if !pbarptr > 0 then print_bar (pfbar | !pbarptr) // Why need 
>> no checking `pbarptr > 0`? 
>> ``` 
>>
>> I think `pbarptr` should depends on `{l:agz}`, not `{l:addr}`. Isn't it? 
>>
>> 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/c125875c-2fb3-4e0d-b709-6eb5e81b655e%40googlegroups.com.

Reply via email to