I wonder if Dart is capable of executing closures in runtime with such delegate support what Groovy is capable of? See this example for better understanding: A Groovy DSL from scratch in 2 hours.
I have a DSL written in Groovy for easily defining MARC library records. I would love to be able to process a similar Dart script natively by binding definition calls to a delegate class in my program.
record {
leader "00000nam a2200000 u 4500"
controlfield "001", "LIB001"
controlfield "005", "20120311123453.0"
datafield("100") {
subfield "a", "Author of record"
}
datafield("245", "0") {
subfield "a", "Title of record"
}
}
You may wonder: why this can't be expressed in JSON? With such a DSL i can do a lot more than expressing data. Because it's embedded you can do anything inside the DSL which is valid in the host language (this case Groovy). You can do a for loop if you have to define the same thing multiple times only with different values, you can use GString expressions, call a database, access files, etc. With a DSLD defined the IDE is knowing your concept just like if it was always part of the language, it can offer you assisting tools. It's highly expressive and intuitive.
A similar thing for Dart is what i'm looking for.