githwxi / ATS-Postiats

ATS2: Unleashing the Potentials of Types and Templates
www.ats-lang.org
Other
352 stars 54 forks source link

Pass Vararg #191

Open steinwaywhw opened 6 years ago

steinwaywhw commented 6 years ago

It seems that we can't pass varargs.

extern fun printf1 {ts:types} (fmt: string, args: ts): void = "mac#printf"

extern fun printf2 {ts:types} (fmt: string, args: ts): void
implement  printf2 {ts} (fmt, args) = printf1 {ts} (fmt, args)

implement main0 () = let
   val _ = printf1 ("%s\n", $vararg("helloworld"))
   val _ = printf2 ("%s\n", $vararg("helloworld")) // can't do this, causing C syntax errors. 
in 
end
Hibou57 commented 6 years ago

Hi,

I have not tried your sample, but there is an example use case of variadic arguments, here: https://github.com/githwxi/ATS-Postiats/blob/master/doc/EXAMPLE/TESTATS/variadic.dats

If it does not help, I may try to look further (just can’t promise).