It was really that simple?  Well, your solution worked.  Thanks, I was 
completely dumbfounded there.

On Tuesday, September 1, 2020 at 6:05:54 PM UTC-4 gmhwxi wrote:

> Please try:
>
> !res_ptr := (@{...} : mesh);
>
>
> On Tue, Sep 1, 2020 at 4:57 PM d4v3y_5c0n3s <tmj...@gmail.com> wrote:
>
>> Good evening,
>>     So, here's a snippet of code where I'm trying to create a record type 
>> that gets allocated within a pointer.  Also, I am trying to allocate arrays 
>> within this record type.  I've been stuck on this for too long, so I was 
>> looking for an outsider's perspective on how I might solve this.
>>     Here's the code (error is highlighted in yellow):
>> absvt@ype mesh
>>
>> local
>>
>> assume mesh =
>> [v,t:int]
>> [vl,tl:addr]
>> @{
>>   v=int v, t=int t, vap=arrayptr(vertex, vl, v), tap=arrayptr(uint32, tl, 
>> t)
>> }
>>
>> in
>>
>> implement mesh_print ( m ) = let
>>   fun vert_print_loop {i,j:int | 0 <= i+1; i+1 <= j} .<i>. ( i: int i, 
>> v_arr: &(arrayptr(vertex, j)) ): void =
>>     if not(i < 0) then begin
>>       vertex_print(v_arr[i]);
>>       vert_print_loop(i-1, v_arr)
>>     end else ()
>>   fun tri_print_loop {i,j:int | 0 <= i+1; i+1 <= j} .<i>. ( i: int i, 
>> t_arr: &(arrayptr(uint32, j)) ): void =
>>     if not(i < 0) then begin
>>       println!(t_arr[i]);
>>       tri_print_loop(i-1, t_arr)
>>     end else ()
>> in
>>   println!("Num Verts: ", m.v);
>>   vert_print_loop(m.v-1, m.vap);
>>   println!("Num Tris: ", m.t);
>>   println!("Triangle Indicies");
>>   tri_print_loop(m.t-1, m.tap)
>> end
>>
>> implement mesh_new (  ) = let
>>   val vert_array = arrayptr_make_uninitized<vertex>(size_of_int(0))
>>   val tri_array = arrayptr_make_uninitized<uint32>(size_of_int(0))
>>   val (res_mpf, res_gcpf | res_ptr) = ptr_alloc<mesh>()
>> in
>>   arrayptr_initize(vert_array, size_of_int(0));
>>   arrayptr_initize(tri_array, size_of_int(0));
>>   !res_ptr := @{
>>     v=0, t=0,
>>     vap=vert_array,
>>     tap=tri_array
>>   }:mesh;
>>   (res_mpf, res_gcpf | res_ptr)
>> end
>>
>> end
>>     Here's the error message:
>> patscc -tcats /home/tmj90/Goldelish-Engine/source/g_engine.dats
>> /home/tmj90/Goldelish-Engine/source/g_engine.dats: 68955(line=2414, 
>> offs=3) -- 69025(line=2418, offs=4): error(3): the dynamic expression 
>> cannot be assigned the type [S2Eexi(v(8781), t(8782); ; S2Eexi(vl(8783), 
>> tl(8784); ; S2Etyrec(flt0; npf=-1; v=S2Eapp(S2Ecst(int); S2Evar(v(8781))), 
>> t=S2Eapp(S2Ecst(int); S2Evar(t(8782))), vap=S2Eapp(S2Ecst(arrayptr); 
>> S2Ecst(vertex), S2Evar(vl(8783)), S2Evar(v(8781))), 
>> tap=S2Eapp(S2Ecst(arrayptr); S2Ecst(uint32), S2Evar(tl(8784)), 
>> S2Evar(t(8782))))))].
>> /home/tmj90/Goldelish-Engine/source/g_engine.dats: 68955(line=2414, 
>> offs=3) -- 69025(line=2418, offs=4): error(3): mismatch of static terms 
>> (tyleq):
>> The actual term is: S2Ecst(atsvoid_t0ype)
>> The needed term is: S2Etyrec(flt0; npf=-1; v=S2Eapp(S2Ecst(int); 
>> S2EVar(7152)), t=S2Eapp(S2Ecst(int); S2EVar(7153)), 
>> vap=S2Eapp(S2Ecst(arrayptr); S2Ecst(vertex), S2EVar(7154), S2EVar(7152)), 
>> tap=S2Eapp(S2Ecst(arrayptr); S2Ecst(uint32), S2EVar(7155), S2EVar(7153)))
>>     Thanks for any help, and let me know if you need more details from 
>> the code.
>> Have a great day,
>>     Troy Jacobs
>>
>> -- 
>> 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 view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ats-lang-users/8fc97318-1f07-4261-a747-70f7edf00747n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/ats-lang-users/8fc97318-1f07-4261-a747-70f7edf00747n%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 ats-lang-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/c495df7f-c9da-43c2-bb2d-97d15ab41fe3n%40googlegroups.com.

Reply via email to