<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#ffffff">
Not sure if I'd call it a "pearl", but here's one data point. Hell,
I'm not even sure if this counts as a DSL or not, most of what I
know of DSLs comes from blog posts and ruby fanatics.<br>
<br>
I had a legacy electronic voting system (IIS/VBscript/SQL Server)
and wrote some lisp to configure elections. The lisp code output
the T-SQL needed to configure the election, and then the VBScript
was driven from that data.<br>
<br>
Here's an abbreviated example:<br>
<br>
(with-election ("3/29/2011 8:00PM" "3/31/2011 7:00PM" "Law")<br>
(with-position ("President" :types '("Law Undergrad"))<br>
(make-candidates "name 1" "name 2" "name 3")) <br>
(make-referendum "Amendment 1" "<strong>Thing To
Change</strong><br>
<p>HTML body for the voting UI</p>"))<br>
<br>
The :types indicated who was eligible to vote for the position, and
there were some other options to those macros. The with-* forms are
macros to setup the context, and the make-* functions generate the
appropriate SQL strings and write them to a stream (usually a file).<br>
<br>
The macros in the sample do a few things: <br>
<ol>
<li>with-election: sets a dynamic variable in lisp for the stream
all the SQL strings are written to in make-* functions, allowed
easy testing of make-* functions via the REPL </li>
<li>with-position: sets a variable in the T-SQL script used by
INSERT statements produced by make-candidates. This actually
macroexpands to imperative code: (progn (make-position ...)
(make-candidates ...)). The macro usage is mostly to get
indentation and visually group the relationships<br>
</li>
</ol>
So, not sure if I'd call this a pearl and it's arguably a DSL, but
it's sure a lot easier for me to use than direct T-SQL or the
ridiculous VBScript web interface.<br>
<br>
Other things I've used that might fall into the DSL category: <br>
<ul>
<li>cl-who <a href="http://weitz.de/cl-who/">http://weitz.de/cl-who/</a></li>
<li>cl-interpol <a href="http://weitz.de/cl-interpol/">http://weitz.de/cl-interpol/</a><br>
</li>
<li>clsql's SQL-READER syntax (<a
href="http://clsql.b9.com/manual/ref-syntax.html">http://clsql.b9.com/manual/ref-syntax.html</a>)</li>
</ul>
HTH,<br>
<pre class="moz-signature" cols="72">Ryan Davis
Acceleration.net
Director of Programming Services
2831 NW 41st street, suite B
Gainesville, FL 32606
Office: 352-335-6500 x 124
Fax: 352-335-6506</pre>
<br>
On 7/20/2011 9:32 AM, Didier Verna wrote:
<blockquote cite="mid:muxk4bdoz6w.fsf@uzeb.lrde.epita.fr"
type="cite">
<pre wrap="">
Dear friends,
I'm starting to write a chapter for an upcoming book on domain specific
languages. The chapter is called (tentatively):
Extensible languages -- blurring the distinction between DSLs and GPLs
GPL meaning General Purpose Language in this context ;-)
My intention is to demonstrate how the task of implementing a DSL is
made easier when it boils down to an extension or subset of your
original GPL (hence reusing its infrastructure), instead of being a
totally different language, only written on top of the other.
Obviously, I'm going to illustrate this with Common Lisp, and I intend
to speak of dynamicity (not only dynamic typing, but in general all
things that can be deferred to the run-time), introspection,
intersession, structural or procedural reflexivity, meta-object
protocols (not sure about this one), macro systems and JIT-compilation.
Also, more specifically to Lisp, reader macros (compiler macros maybe?),
the condition system (and its ability to *not* unwind) and restarts.
Right now, I would like to know if any of you have DSL "pearls", nice
examples of DSLs that you have written in Lisp by using some of its
features in a clever or elegant way. I would also gladly accept any
point of view or comment on what's important to mention, in terms of
design principle or anything else, things that I may have missed in the
list above.
Thank you very much in advance!
</pre>
</blockquote>
</body>
</html>