unfortunately, I have problem when using separate files for this code
snippet.
If I use three files get_value.sats, get_value.dats and main.dats, I
cannot make it working…
— get_value.sats —
datatype color = Black | Red
datatype tree (a:t@ype) =
Empty(a) of ()
| Leaf(a) of (color, tree a, a, tree a)
fun{a:t@ype} add_x(w: a, x: a): a
fun{a:t@ype} get_value(t: tree a, x: a) : a
— get_value.dats —
staload “get_value.sats”
implement add_x(w,x) = w + x
implement add_x(w,x) = w + x
implement{a} get_value(t, x) = case+ t of
| Leaf(_, _, v0, _) => add_x(v0, x)
| _ => x
— main.dats —
staload “get_value.sats”
dynload “get_value.dats” // I put dynamic here so add_x defined in
get_value.dats can be seen
implement main(argc, argv) = () where {
val () = print(get_value(Leaf(Black, Empty, 10.1f, Empty),
3.14159f)) // for floats
val () = print_newline()
val () = print(get_value(Leaf(Black, Empty, 10, Empty), 31)) // for
integers
val () = print_newline()
}
I compile with : @ atscc -o test get_value.sats get_value.dats main.dats
and the error is : main.dats: 489(line=24, offs=18) – 505(line=24,
offs=34): error(ccomp): the template definition for [get_value] is
unavailable at [get_value$1696_ats_float_type].You need to add a line:
staload “get_value.sats”
staload _(anon) = “get_value.dats” // add this one
dynload “get_value.dats” // I put dynamic here so add_x defined in
get_value.dats can be seen
I added the line but still have an error :
get_value.dats: 163(line=5, offs=26) – 168(line=5, offs=31): error(ccomp):
the template definition for [add_x] is unavailable at
[add_x$1695_ats_float_type].