News for hackers. Stuff that matters.
Re:Typed, modular macros for OCaml by lacampbell on Saturday November 26, 2016 @07:29PM (#13046923)
Can someone tell me why I would want statically typed macros? Why not just simply type check after macro expansion phase? Seems a lot simpler and more intuitive.

It strongly feels like a case of everything looks like a nail when you really like hammers (static typing), but I am willing to be proven wrong.

Re:Typed, modular macros for OCaml by sordina on Saturday November 26, 2016 @07:39PM (#13046964)
There may be a bunch of other reasons, but the one that springs to mind is localisation of errors. You'd ideally like to know about any mistakes you've made in your macro before you run your macro. And when you do learn about a mistake you'd like the error to describe where the mistake is in macro-land rather than generated-code land.
Re:Typed, modular macros for OCaml by junke on Sunday November 27, 2016 @03:04AM (#13048255)
Why just type errors? You might want to trace any error that occurs at runtime back to the original source code anyway.
Re:Typed, modular macros for OCaml by sordina on Monday November 28, 2016 @07:02AM (#13054863)
I agree, you may wish to do that but I was answering the question "What is the utility of typed-templates", not "contrast type and runtime error tradeoffs".
Re:Typed, modular macros for OCaml by otini on Sunday November 27, 2016 @07:57AM (#13048914)
Firstly, if your macro does not typecheck, it means that executing it might result in a segfault or something similar, since macros are regular OCaml functions. Secondly, if macro typechecks, then it is guaranteed to expand without errors, and I think that's a nice guarantee to have.
Re:Typed, modular macros for OCaml by lacampbell on Sunday November 27, 2016 @01:06PM (#13050409)
> Firstly, if your macro does not typecheck, it means that executing it might result in a segfault or something similar, since macros are regular OCaml functions.

I see. The only time I've extensively used (real) macros has been with racket, where they aren't regular functions at all. I suppose my ignorance of Ocaml macros is showing here.

Re:Typed, modular macros for OCaml by adamnemecek on Saturday November 26, 2016 @08:10PM (#13047102)
Look at the C++ templates, I think that some of the clusterfuck that is C++ template compiler errors would go away if templates were type aware.