Arrayptr encapsulation

hello,
I could not figure out how to make working this simple piece code :

#include “share/atspre_staload_tmpdef.hats”

absvtype vector3_vt(a:t@ype) = ptr

extern fun{a:t@ype} vec3_vt_create (x: a, y: a, z: a): vector3_vt(a)
extern fun{a:t@ype} vec3_vt_delete (v: vector3_vt(a)): void

local
assume vector3_vt(a) = arrayptr(a, 3)
in
implement{a} vec3_vt_create(x,y,z) = arrayptr $arrpsz{a}(x,y,z)
implement{a} vec3_vt_delete(v) = arrayptr_free{a} v
end

implement main0() = let
val v2 = vec3_vt_create(3,2,1)
in
vec3_vt_delete v2
end

I tried also :

#include “share/atspre_staload_tmpdef.hats”

viewtypedef vector3_vt(a:t@ype) = arrayptr(a,3)

extern fun{a:t@ype} vec3_vt_create (x: a, y: a, z: a): vector3_vt(a)
extern fun{a:t@ype} vec3_vt_delete (v: vector3_vt(a)): void

implement{a} vec3_vt_create(x,y,z) = arrayptr $arrpsz{a}(x,y,z)
implement{a} vec3_vt_delete(v) = arrayptr_free{a} v

implement main0() = let
val v2 = vec3_vt_create(3,2,1)
in
vec3_vt_delete v2
end

The two solutions raise the same compilation error :

test_abs_dats.c: In function
’_057$usr_057$users_057$cydu_057$programming_057$ATS_057$DEV_057$ats3d_057$test_057$test_mat_057$test_abs_056$dats_vec3_vt_create$0$1’:
test_abs_dats.c:432: error: ‘tmp1’ undeclared (first use in this function)
test_abs_dats.c:432: error: (Each undeclared identifier is reported only
once
test_abs_dats.c:432: error: for each function it appears in.)
test_abs_dats.c:440: error: ‘tmp2’ undeclared (first use in this function)

great !

Well, you triggered a feature that had never been tested before.

I fixed problem and git-pushed the changes.

Also, I tidied up your code a bit and put it here:

Cheers!