I'd like to implement a similar macro but don't know how.This is for binary printing of values (to write binary files easily if error reporting is of little concern). At first I thought that co-opting fprint_val/fprint_ref would be enough, but now I think the user would have to staload the overriden template instantiations for basic types (and a host of other types, e.g. lists, etc.), which can be quite puzzling.
--
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 ats-lang-user...@googlegroups.com.
To post to this group, send email to ats-lan...@googlegroups.com.
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/75a62ff5-d0ca-405a-a906-59d7b927677a%40googlegroups.com.
print! and fprint! are handled by the compiler in a special way:There is currently no support for doing this outside the compiler.
https://github.com/githwxi/ATS-Postiats/blob/master/src/pats_trans1_syndef.dats
#include"share/atspre_staload.hats"
local
macrodefrecauxlist (xs, y) =(//if iscons! (xs) then `(print ,(car! xs); ,(auxlist (cdr! xs, y)))else y // end of [if]//) // end of [auxlist]
in (* in of [local] *)
macdefprint_mac (x) =,( if islist! (x) then auxlist (x, `()) else `(print ,(x))) // end of [print_mac]
macdefprintln_mac (x) =,( if islist! (x) then auxlist (x, `(print_newline())) else `(print ,(x)) // end of [if]) // end of [println_mac]
end // end of [local]
implementmain0 () = { val () = println_mac ("the value is: ", 2*2)}admin@artyom-laptop:ats$patscc lmacrodeftest.dats/home/admin/org/ats/lmacrodeftest.dats: 576(line=38, offs=12) -- 611(line=38, offs=47): error(mac): the form of dynamic expression [D2Esing(D2Eifhead(D2Emacfun(iscons; D2Evar(xs$3803(-1))); D2Emacsyn(MSKencode; D2Eseq(D2Eapplst(D2Esym(print); D2EXPARGdyn(-1; D2Emacsyn(MSKdecode; D2Emacfun(car; D2Evar(xs$3803(-1)))))), D2Emacsyn(MSKdecode; D2Eapplst(D2Emac(auxlist); D2EXPARGdyn(-1; D2Emacfun(cdr; D2Evar(xs$3803(-1))), D2Evar(y$3804(-1))))))); Some(D2Evar(y$3804(-1)))))] is unsupported for macro expansion./home/admin/org/ats/lmacrodeftest.dats: 576(line=38, offs=12) -- 611(line=38, offs=47): error(mac): the expansion of the dynamic expression at (/home/admin/org/ats/lmacrodeftest.dats: 391(line=29, offs=3) -- 466(line=30, offs=60)) is expected to return code (AST) but it does not./home/admin/org/ats/lmacrodeftest.dats: 571(line=38, offs=7) -- 573(line=38, offs=9): error(3): the void pattern is ill-typed./home/admin/org/ats/lmacrodeftest.dats: 571(line=38, offs=7) -- 573(line=38, offs=9): error(3): mismatch of static terms (tyleq):The actual term is: S2Ecst(atsvoid_t0ype)The needed term is: S2Eerr()patsopt(TRANS3): there are [2] errors in total.exit(ATS): uncaught exception: _2home_2admin_2postiats_2src_2pats_error_2esats__FatalErrorExn(1025)To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/880affc7-d82b-48b7-a67f-ecbab9cb00f0%40googlegroups.com.
I see. I think this can be made to work as expected.I need to do a bit reverse engineering to figure it out.
To unsubscribe from this group and stop receiving emails from it, send an email to ats-lang-users+unsubscribe@googlegroups.com.
To post to this group, send email to ats-lang-users@googlegroups.com.