6 ms·
I think you are describing a source to source translator, and an awfully fancy one at that. A translator generally would be trying to map or maintain the struct
by saltcured 9y ago
I think you are describing a source to source translator, and an awfully fancy one at that. A translator generally would be trying to map or maintain the structural idioms in the source code, allowing for human understanding or maintenance of the translated code. But to improve the coding style by detecting latent idioms seems a bit much even for most translators.
I always considered a transpiler to be closer to a translator than to a compiler, but without the translator's concern for maintaining human-readable code. For me, the boundary between transpiler and compiler is in the runtimes.
A transpiler would be targeting the whole runtime of a target language, i.e. one with non-trivial type systems, flow control/exception handling, and memory management/GC. The transpiler maps source language runtime concepts to target language runtime concepts in a relatively straightforward fashion. A compiler targets some lower-level abstract machine language and provides its own distinct runtime system as well.
A similar boundary exists for interpreters, where a meta-interpreter does relatively high-level source-to-source conversion before delegating to a target language interpreter and its runtime. These meta-interpreters are akin to transpilers, while full blown interpreters are akin to compilers, targeting a lower level abstract machine and providing their own runtime systems.
- tom_mellior 9y ago> where a meta-interpreter does relatively high-level source-to-source conversion before delegating to a target language interpreter This is most emphatically not what Prolog meta-interpreters do. (Those are the ones I am most familiar with.) They do not build up new source code, they interpret given terms in "new" ways that are not built into the Prolog implementation. Systems that build new source code are called expansions or sometimes macros. I don't think the Lisp world would call such systems meta-interpreters either. There, too, you have macros that transform source code. Do you have a reference that uses the term "meta-interpreter" in the way you are describing?
- saltcured 9y agoSorry, it's been many years and I misremembered the term "meta-circular evaluator", i.e. everybody's toy implementation of an interpreter with a REPL and very simplistic (if any) changes to the source language being interpreted.