3 ms·
This lets you embed programs in other languages (DSLs) within your program that are parsed and compiled at compile time instead of run-time. This has the follo
by bickfordb 15y ago
This lets you embed programs in other languages (DSLs) within your program that are parsed and compiled at compile time instead of run-time. This has the following benefits over run-time DSLs / languages embedded inside of strings:
1. The embedded language will be type checked at compile time. For example a regular expression macro could enforce that your regular expression has balanced parentheses in capture groups. This potentially lets you shift a class of errors from run-time to compile time.
2. The language will be parsed at compile time saving run-time cycles.
3. The host language can be extended and experimented with without adding new syntax. Features like this actually limit the growth of the "dog pile", since many language experiments features can be tested as macros first.
Some common DSL examples are regular expressions, parser generators, SQL / ORM generators and LINQ