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
--
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/a763cecd-5120-4c97-b3bb-4537501adadf%40googlegroups.com.