Here is a way to make it work:
%{^
#undef ATSextfcall
#define ATSextfcall(f, xs) f xs
#define foo(x) ((x) >> 1)
%}
extern
fun
{tk:tkind}
foo: {i:int}(g1int (tk, i)) -<> [j:int] g1int (tk, j)
implement
{tk}
foo (x) = let
typedef res = [j:int] g1int(tk, j)
in
$extfcall (res, “foo”, x)
end // end of [foo]
implement
main0 () =
{
val I = 16
val () = println! (“foo(”, I, ") = ", foo(I))
val L = 16L
val () = println! (“foo(”, L, ") = ", foo(L))
val LL = 16LL
val () = println! (“foo(”, LL, ") = ", foo(LL))
}On Sunday, October 5, 2014 11:25:05 PM UTC-4, Barry Schwartz wrote:
Something like
%{^
#define foo(x) ((x) >> 1)
%}extern fun {tk : tkind} foo :
{i : int} (g1int (tk, i)) -<> [j : int] g1int (tk, j))
= “mac#”doesn’t work, does it? Even though the C is agnostic about which
integer type is needed? On account of foo being a template rather than
a function proper.I have something like that and it does not seem to work. If I am
right, what is the best alternative? Something tedious as appears in
integer.{s,d,c}ats?(It’s the sort of job one rolls m4 scripts to do.)