An escape hatch is an “adapter” language feature, used to embed a fragment written in a lower-level language inside a larger fragment written in a higher-level language.
An example from the world of general-purpose programming languages (GPLs): many C compilers let you embed inline assembly (a lower-level language) in your C code (a higher-level language). Here is an example of inline assembly in GCC (GNU C Compiler) syntax for an Intel architecture processor:
/* Add 10 and 20 and store result into register %eax */ __asm__ ( "movl $10, %eax;" "movl $20, %ebx;" "addl %ebx, %eax;" );
And it goes further: if your assembler does not know how to translate a particular CPU instruction, you can use a
db instruction to emit bytes directly into the output. This is an escape hatch from assembly into machine
In the context of MPS-based DSLs there are multiple examples of escape hatches.
Many MPS languages use query functions (also called concept functions) to let you write logic in Java where predefined constant values are not enough.
The MPS build language, whose job it is to generate Ant files from a higher level description of your project modules and their dependencies, lets you embed bits of Ant XML into your build files.
Escape hatches give power to language users. Without an escape hatch they might have to postpone their work and pressure you, the DSL developer, to publish a new release of your DSL. A well-designed escape hatch may help them work around a missing feature in the DSL and get on with their work, releasing the pressure on you. And by seeing their workarounds you might also get a better idea of the semantics of the missing feature.
Therefore, avoid building escape hatches that lead directly to your implementation language. But do build escape hatches to lower-level technology-independent languages.