The following code works as is:
#include "share/atspre_staload.hats"
implement main0(argc, argv) =
let
val who = (if argc > 1 then argv[1] else "world")
in
if argc > 1 then
println!("Hello, ", argv[1], "!");
print_string("Hello, ");
print_string(who);
print_string("!");
print_newline();
end
And is used like this:
$ patscc -O2 -flto -D_GNU_SOURCE -DATS_MEMALLOC_LIBC main3.dats -o main3 -latslib
$ ./main3
Hello, world!
$ ./main3 bob
Hello, bob!
Hello, bob!
If however the `argv[1]` in `println!` is changed to `who`,
#include "share/atspre_staload.hats"
implement main0(argc, argv) =
let
val who = (if argc > 1 then argv[1] else "world")
in
if argc > 1 then
println!("Hello, ", who, "!");
print_string("Hello, ");
print_string(who);
print_string("!");
print_newline();
end
then it fails to compile:
main3.dats: 161(line=8, offs=7) -- 190(line=8, offs=36): error(3): the symbol [print] cannot be resolved due to too many matches:
D2ITMcst(print_option) of 0
D2ITMcst(print_list_vt) of 0