I am thinking of implementing a template template using only plain C # /. NET 4 syntax with regard to static typing.
Then on top of this template language, we could create domain-specific languages (say, HTML4, XHTML, HTML5, RSS, Atom, multi-page emails, etc.).
One of the best DSLs in .NET 4 (if not just one) is SharpDOM . It implements HTML-specific DSLs.
Looking at SharpDOM, I'm really impressed with what you can do using .NET (4).
So, I believe that there are some not very well-known ways to implement custom DSL in .NET 4. Perhaps this is not the case in Ruby, but still.
So my question is: what are the features of C # (4) syntax that can be used to implement custom DSLs?
Examples I can think of now:
div(clas: "head",
ul(clas: "menu", id: "main-menu", () => {
foreach(var item in allItems) {
li(item.Name)
}
})
)
Line("Dear {0}", user.Name);
Line("You have been kicked off from this site");
It is very difficult for me to come up with the syntax with the least amount of noise .
Please note that I am not talking about another language (Boo, IronRuby, etc.), and I'm not talking about different template mechanisms (NHaml, Spark, StringTemplate, etc.).