DeRailed DSL (was Re: compile-time regex redux)
Andrei Alexandrescu (See Website For Email)
SeeWebsiteForEmail at erdani.org
Sat Feb 10 23:10:58 PST 2007
Walter Bright wrote:
> Sean Kelly wrote:
>> Please note that I'm not criticizing in-language DSL parsing as a
>> general idea so much as questioning whether this is truly the best
>> example for the usefulness of such a feature.
>
> Compile time DSL's will really only be useful for relatively small
> languages. For a complex DSL, a separate compilation tool will be
> probably much more powerful and much more useful.
True, but then there's also the scavenging approach: a small DSL can be
a reduced interpretation of a complex language. For example, one can
imagine parsing an HTML file to extract stuff of interest, while
literally skipping over the complexity of HTML (and javascript).
And I've already given the example of parsing SQL code to generate a D
mapping. I've actually done this in 1998: starting from CREATE VIEW
statements, I was generating C++ code with one struct per view.
> I don't know anything about database languages, so I'm no help there.
>
> One example of a highly useful compile time DSL is the regex package
> that Don Clugston and Eric Anderton put together. With better
> metaprogramming support, this kind of thing will become much simpler to
> write.
>
> There's often a need for custom 'little languages' for lots of projects.
> Most of the time, people just make do without them because they aren't
> worth the effort to create. I hope to make it so easy to create them,
> that all kinds of unforeseen uses will be made of them.
>
> I'll give an example: I often have a need to create parallel tables of
> data. C, C++, and D have no mechanism to do that directly (though I've
> used a macro trick to do it in C). With a DSL, this becomes easy.
And parallel hierarchies required by some design patterns are a bitch.
With code generation it will be easy to rein in.
Andrei
More information about the Digitalmars-d
mailing list