Makarius wrote:
On Fri, 7 Dec 2007, Basile STARYNKEVITCH wrote:
Does PolyML provide facilities to generate (machine) code at runtime (on Linux/AMD64 or Linux/x86), either in a type safe way (in the spirit of MetaML or MetaOcaml) or in a more low level unsafe way (e.g. like LLVM, Libjit, GNU lightning, ....)
Poly/ML is an ``incremental compiler'' and always produces native code, even at runtime. The mechanism for this is similar to traditional EVAL in Lisp, but the code is properly compiled and type-checked (only at runtime-compilation-evaluation, though).
While this is not proper meta programming, it works very smoothly. We are using this facility on an everyday basis in the Isabelle system http://isabelle.in.tum.de/
The most basic way is to invoke PolyML.use on source files.
There is no way to at least work on abstract syntax tree? While generating code as string (or files) is definitely doable, it is not really convenient. Besides, its also have a cost (both in the human developer's coding time and in the machine time to print & reparse it) which I would be interested to avoid.
IIRC, some old SML/NJ implementations had public modules to manipulate these AST without having to print & reparse them.