<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-21789874</id><updated>2012-01-27T11:18:15.005-07:00</updated><category term='fun'/><category term='postgresql'/><category term='racket'/><category term='databases'/><category term='macros'/><title type='text'>one racketeer</title><subtitle type='html'>Ryan Culpepper
on macros, functional programming, and programming language research</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://macrologist.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21789874/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://macrologist.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Ryan Culpepper</name><uri>http://www.blogger.com/profile/04275692281825651783</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>8</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-21789874.post-1268372381708055046</id><published>2011-10-31T07:00:00.000-06:00</published><updated>2011-11-13T11:22:21.953-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='databases'/><category scheme='http://www.blogger.com/atom/ns#' term='racket'/><category scheme='http://www.blogger.com/atom/ns#' term='postgresql'/><title type='text'>in praise of PostgreSQL arrays</title><content type='html'>&lt;p&gt;I just added support for
&lt;a href="http://www.postgresql.org/docs/current/static/arrays.html"&gt;PostgreSQL
arrays&lt;/a&gt; to the &lt;a href="http://pre.racket-lang.org/docs/html/db/index.html" class="RktModLink" pltdoc="x"&gt;&lt;span class="RktSym"&gt;db&lt;/span&gt;&lt;/a&gt; library. While there are some uses
of arrays that are iffy from a database design standpoint, there’s one
use that weighs overwhelmingly in their favor: avoiding dynamic
generation of SQL &lt;span class="stt"&gt;IN&lt;/span&gt; comparisons.&lt;/p&gt;
&lt;a href="http://macrologist.blogspot.com/2011/10/in-praise-of-postgresql-arrays.html#more"&gt;Read more »&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21789874-1268372381708055046?l=macrologist.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://macrologist.blogspot.com/feeds/1268372381708055046/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21789874&amp;postID=1268372381708055046' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21789874/posts/default/1268372381708055046'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21789874/posts/default/1268372381708055046'/><link rel='alternate' type='text/html' href='http://macrologist.blogspot.com/2011/10/in-praise-of-postgresql-arrays.html' title='in praise of PostgreSQL arrays'/><author><name>Ryan Culpepper</name><uri>http://www.blogger.com/profile/04275692281825651783</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21789874.post-8382615913110244546</id><published>2011-10-27T00:46:00.000-06:00</published><updated>2011-10-27T00:46:58.143-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='fun'/><title type='text'>the Soylent Green Theory of Presentations</title><content type='html'>&lt;p&gt;It’s
people.... &lt;a href="http://www.youtube.com/watch?v=8Sp-VFBbjpE"&gt;&lt;span style="font-style: italic"&gt;The
audience is made of people!&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
&lt;a href="http://macrologist.blogspot.com/2011/10/soylent-green-theory-of-presentations.html#more"&gt;Read more »&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21789874-8382615913110244546?l=macrologist.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://macrologist.blogspot.com/feeds/8382615913110244546/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21789874&amp;postID=8382615913110244546' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21789874/posts/default/8382615913110244546'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21789874/posts/default/8382615913110244546'/><link rel='alternate' type='text/html' href='http://macrologist.blogspot.com/2011/10/soylent-green-theory-of-presentations.html' title='the Soylent Green Theory of Presentations'/><author><name>Ryan Culpepper</name><uri>http://www.blogger.com/profile/04275692281825651783</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21789874.post-4125465791550727547</id><published>2011-10-16T23:28:00.000-06:00</published><updated>2011-10-16T23:28:03.299-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='racket'/><category scheme='http://www.blogger.com/atom/ns#' term='macros'/><title type='text'>lazy module loading</title><content type='html'>&lt;p&gt;The Racket module system is good at managing dependencies. When you
&lt;span class="RktSym"&gt;&lt;a href="http://docs.racket-lang.org/reference/require.html#(form._((lib._racket%2Fprivate%2Fbase..rkt)._require))" class="RktStxLink" pltdoc="x"&gt;require&lt;/a&gt;&lt;/span&gt; a module, you ensure that that module is initialized
before your code runs, and when the other module changes, the compiler
will notice and recompile your module too. Racket even stratifies
dependencies according to &lt;a href="http://docs.racket-lang.org/guide/stx-phases.html" pltdoc="x"&gt;phase
levels&lt;/a&gt; so you can use some modules in your macro implementations and
other modules in your run-time code and the expander/compiler/linker
knows
&lt;a href="http://www.cs.utah.edu/plt/publications/macromod.pdf"&gt;what
you want when&lt;/a&gt;. It keeps track and makes sure that everything is
loaded and available when it’s supposed to be.&lt;/p&gt;&lt;p&gt;But sometimes you want to manage dependencies yourself. This post
is about how to &lt;span style="font-style: italic"&gt;lazily load&lt;/span&gt; the implementations of functions
and—&lt;wbr&gt;&lt;/wbr&gt;with a bit of care—&lt;wbr&gt;&lt;/wbr&gt;even macros.&lt;/p&gt;
&lt;a href="http://macrologist.blogspot.com/2011/10/lazy-module-loading.html#more"&gt;Read more »&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21789874-4125465791550727547?l=macrologist.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://macrologist.blogspot.com/feeds/4125465791550727547/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21789874&amp;postID=4125465791550727547' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21789874/posts/default/4125465791550727547'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21789874/posts/default/4125465791550727547'/><link rel='alternate' type='text/html' href='http://macrologist.blogspot.com/2011/10/lazy-module-loading.html' title='lazy module loading'/><author><name>Ryan Culpepper</name><uri>http://www.blogger.com/profile/04275692281825651783</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21789874.post-9107679359777761936</id><published>2011-09-27T04:03:00.001-06:00</published><updated>2011-09-28T02:01:40.170-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='racket'/><category scheme='http://www.blogger.com/atom/ns#' term='macros'/><title type='text'>definitions vs enclosing binding forms</title><content type='html'>&lt;p&gt;There are two kinds of binding forms in Racket: definitions and
enclosing binding forms. The scope of a binding introduced by an
enclosing binding form is entirely evident: it’s one (or more) of the
form’s sub-terms. For example, in&lt;/p&gt;&lt;blockquote class="SCodeFlow"&gt;&lt;p&gt;&lt;span class="RktPn"&gt;(&lt;/span&gt;&lt;span class="RktSym"&gt;&lt;a href="http://docs.racket-lang.org/reference/lambda.html#(form._((lib._racket%2Fprivate%2Fbase..rkt)._lambda))" class="RktStxLink" pltdoc="x"&gt;lambda&lt;/a&gt;&lt;/span&gt;&lt;span class="hspace"&gt; &lt;/span&gt;&lt;span class="RktPn"&gt;(&lt;/span&gt;&lt;span class="RktVar"&gt;var&lt;/span&gt;&lt;span class="hspace"&gt; &lt;/span&gt;&lt;span class="RktSym"&gt;&lt;a href="http://docs.racket-lang.org/reference/stx-patterns.html#(form._((lib._racket%2Fprivate%2Fstxcase-scheme..rkt)._......))" class="RktStxLink" pltdoc="x"&gt;...&lt;/a&gt;&lt;/span&gt;&lt;span class="RktPn"&gt;)&lt;/span&gt;&lt;span class="hspace"&gt; &lt;/span&gt;&lt;span class="RktVar"&gt;body&lt;/span&gt;&lt;span class="RktPn"&gt;)&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;the scope of the &lt;span class="RktVar"&gt;var&lt;/span&gt; bindings is &lt;span class="RktVar"&gt;body&lt;/span&gt;. In
contrast, the scope of a definition is determined by its context: the
enclosing &lt;span class="RktSym"&gt;&lt;a href="http://docs.racket-lang.org/reference/lambda.html#(form._((lib._racket%2Fprivate%2Fbase..rkt)._lambda))" class="RktStxLink" pltdoc="x"&gt;lambda&lt;/a&gt;&lt;/span&gt; body, for example, or the enclosing
module—&lt;wbr&gt;&lt;/wbr&gt;except that scope is too simple a term for how bindings work
in such contexts. Enclosing binding forms are simpler and cleaner but
weaker; definition forms are more powerful, but have a more
complicated binding structure. Definitions also have the pleasant
property of reducing rightward code drift.&lt;/p&gt;
&lt;a href="http://macrologist.blogspot.com/2011/09/definitions-vs-enclosing-binding-forms.html#more"&gt;Read more »&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21789874-9107679359777761936?l=macrologist.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://macrologist.blogspot.com/feeds/9107679359777761936/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21789874&amp;postID=9107679359777761936' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21789874/posts/default/9107679359777761936'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21789874/posts/default/9107679359777761936'/><link rel='alternate' type='text/html' href='http://macrologist.blogspot.com/2011/09/definitions-vs-enclosing-binding-forms.html' title='definitions vs enclosing binding forms'/><author><name>Ryan Culpepper</name><uri>http://www.blogger.com/profile/04275692281825651783</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21789874.post-2636267093988199734</id><published>2011-09-09T02:49:00.002-06:00</published><updated>2011-09-28T03:51:15.511-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='racket'/><category scheme='http://www.blogger.com/atom/ns#' term='macros'/><title type='text'>syntax-parse and literals</title><content type='html'>&lt;p&gt;In
&lt;a href="http://macrologist.blogspot.com/2011/09/macros-and-literals.html"&gt;my
last post&lt;/a&gt;, I talked about macros and referential auxiliary
identifiers—&lt;wbr&gt;&lt;/wbr&gt;what we usually call a macro’s “literals.” Scheme
macro systems only get it half right, though, because while they
compare identifiers using referential equality (i.e., using the
&lt;span class="RktSym"&gt;&lt;a href="http://docs.racket-lang.org/reference/stxcmp.html#(def._((quote._~23~25kernel)._free-identifier~3d~3f))" class="RktValLink" pltdoc="x"&gt;free-identifier=?&lt;/a&gt;&lt;/span&gt; predicate), they allow literals to refer to
nonexistent bindings. While the comparison is well-defined via the
definition of &lt;span class="RktSym"&gt;&lt;a href="http://docs.racket-lang.org/reference/stxcmp.html#(def._((quote._~23~25kernel)._free-identifier~3d~3f))" class="RktValLink" pltdoc="x"&gt;free-identifier=?&lt;/a&gt;&lt;/span&gt;, at a higher level the idea
is nonsensical.&lt;/p&gt;&lt;p&gt;In contrast, &lt;span class="RktSym"&gt;&lt;a href="http://docs.racket-lang.org/syntax/Parsing_Syntax.html#(form._((lib._syntax%2Fparse..rkt)._syntax-parse))" class="RktStxLink" pltdoc="x"&gt;syntax-parse&lt;/a&gt;&lt;/span&gt; requires that every literal
refer to some binding. (I’ll sometimes refer to this requirement as
the &lt;span style="font-style: italic"&gt;is-bound&lt;/span&gt; property for short.) This requirement is
problematic in a different way. Specifically, this property cannot be
checked statically (that is, when the syntax-parse expression
containing the literal is compiled).&lt;/p&gt;&lt;p&gt;That might strike you as bizarre or unlikely. After all, you can
easily imagine checking that a &lt;span class="RktSym"&gt;&lt;a href="http://docs.racket-lang.org/reference/stx-patterns.html#(form._((lib._racket%2Fprivate%2Fstxcase-scheme..rkt)._syntax-rules))" class="RktStxLink" pltdoc="x"&gt;syntax-rules&lt;/a&gt;&lt;/span&gt; macro, say,
satisfies the &lt;span style="font-style: italic"&gt;is-bound&lt;/span&gt; property. But in Racket, not every macro
uses &lt;span class="RktSym"&gt;&lt;a href="http://docs.racket-lang.org/reference/stx-patterns.html#(form._((lib._racket%2Fprivate%2Fstxcase-scheme..rkt)._syntax-rules))" class="RktStxLink" pltdoc="x"&gt;syntax-rules&lt;/a&gt;&lt;/span&gt;, and—more importantly—not every bit of
syntax-analyzing code is a macro. And both of these facts have to do
with &lt;a href="http://docs.racket-lang.org/reference/eval-model.html#(tech._phase)" class="techoutside" pltdoc="x"&gt;&lt;span class="techinside"&gt;phases&lt;/span&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;a href="http://macrologist.blogspot.com/2011/09/syntax-parse-and-literals.html#more"&gt;Read more »&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21789874-2636267093988199734?l=macrologist.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://macrologist.blogspot.com/feeds/2636267093988199734/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21789874&amp;postID=2636267093988199734' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21789874/posts/default/2636267093988199734'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21789874/posts/default/2636267093988199734'/><link rel='alternate' type='text/html' href='http://macrologist.blogspot.com/2011/09/syntax-parse-and-literals.html' title='syntax-parse and literals'/><author><name>Ryan Culpepper</name><uri>http://www.blogger.com/profile/04275692281825651783</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21789874.post-3098379947057422422</id><published>2011-09-07T23:08:00.002-06:00</published><updated>2011-09-28T03:30:14.473-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='racket'/><category scheme='http://www.blogger.com/atom/ns#' term='macros'/><title type='text'>macros and literals</title><content type='html'>&lt;p&gt;Macros often have associated auxiliary identifiers (sometimes called
&lt;span style="font-style: italic"&gt;keywords&lt;/span&gt; or &lt;span style="font-style: italic"&gt;reserved words&lt;/span&gt;, although both terms are
problematic in Racket). For example, &lt;span class="RktSym"&gt;&lt;a href="http://docs.racket-lang.org/reference/if.html#(form._((lib._racket%2Fprivate%2Fletstx-scheme..rkt)._cond))" class="RktStxLink" pltdoc="x"&gt;cond&lt;/a&gt;&lt;/span&gt; has &lt;span class="RktSym"&gt;&lt;a href="http://docs.racket-lang.org/reference/if.html#(form._((lib._racket%2Fprivate%2Fletstx-scheme..rkt)._else))" class="RktStxLink" pltdoc="x"&gt;else&lt;/a&gt;&lt;/span&gt;;
&lt;span class="RktSym"&gt;&lt;a href="http://docs.racket-lang.org/reference/createclass.html#(form._((lib._racket%2Fprivate%2Fclass-internal..rkt)._class))" class="RktStxLink" pltdoc="x"&gt;class&lt;/a&gt;&lt;/span&gt; has &lt;span class="RktSym"&gt;&lt;a href="http://docs.racket-lang.org/reference/createclass.html#(form._((lib._racket%2Fprivate%2Fclass-internal..rkt)._public))" class="RktStxLink" pltdoc="x"&gt;public&lt;/a&gt;&lt;/span&gt;, &lt;span class="RktSym"&gt;&lt;a href="http://docs.racket-lang.org/reference/createclass.html#(form._((lib._racket%2Fprivate%2Fclass-internal..rkt)._private))" class="RktStxLink" pltdoc="x"&gt;private&lt;/a&gt;&lt;/span&gt;, etc;
&lt;span class="RktSym"&gt;&lt;a href="http://docs.racket-lang.org/reference/creatingunits.html#(form._((lib._mzlib%2Funit..rkt)._unit))" class="RktStxLink" pltdoc="x"&gt;unit&lt;/a&gt;&lt;/span&gt; has &lt;span class="RktSym"&gt;&lt;a href="http://docs.racket-lang.org/reference/creatingunits.html#(form._((lib._mzlib%2Funit..rkt)._import))" class="RktStxLink" pltdoc="x"&gt;import&lt;/a&gt;&lt;/span&gt; and &lt;span class="RktSym"&gt;&lt;a href="http://docs.racket-lang.org/reference/creatingunits.html#(form._((lib._mzlib%2Funit..rkt)._export))" class="RktStxLink" pltdoc="x"&gt;export&lt;/a&gt;&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;The fundamental question is what constitutes a use of an auxiliary
identifier, and there are two reasonable answers: &lt;span style="font-style: italic"&gt;symbolic
equality&lt;/span&gt; and &lt;span style="font-style: italic"&gt;referential equality&lt;/span&gt;. By symbolic equality I
mean, for example, that any identifier written with exactly the
letters &lt;span class="stt"&gt;else&lt;/span&gt; is accepted as an &lt;span class="RktSym"&gt;&lt;a href="http://docs.racket-lang.org/reference/if.html#(form._((lib._racket%2Fprivate%2Fletstx-scheme..rkt)._else))" class="RktStxLink" pltdoc="x"&gt;else&lt;/a&gt;&lt;/span&gt; auxiliary form. By
referential equality I mean any identifier that &lt;span style="font-style: italic"&gt;refers to&lt;/span&gt;
(using the standard notions of binding, environments, etc) the binding
identified as the &lt;span class="RktSym"&gt;&lt;a href="http://docs.racket-lang.org/reference/if.html#(form._((lib._racket%2Fprivate%2Fletstx-scheme..rkt)._else))" class="RktStxLink" pltdoc="x"&gt;else&lt;/a&gt;&lt;/span&gt; binding.&lt;/p&gt;
&lt;a href="http://macrologist.blogspot.com/2011/09/macros-and-literals.html#more"&gt;Read more »&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21789874-3098379947057422422?l=macrologist.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://macrologist.blogspot.com/feeds/3098379947057422422/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21789874&amp;postID=3098379947057422422' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21789874/posts/default/3098379947057422422'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21789874/posts/default/3098379947057422422'/><link rel='alternate' type='text/html' href='http://macrologist.blogspot.com/2011/09/macros-and-literals.html' title='macros and literals'/><author><name>Ryan Culpepper</name><uri>http://www.blogger.com/profile/04275692281825651783</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21789874.post-6627086331393105770</id><published>2011-08-31T20:38:00.001-06:00</published><updated>2011-08-31T20:39:23.199-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='databases'/><category scheme='http://www.blogger.com/atom/ns#' term='racket'/><title type='text'>asynchonous execution for databases, using places</title><content type='html'>&lt;p&gt;
I added asynchronous execution to &lt;a href="http://pre.racket-lang.org/docs/html/db/"&gt;my database library&lt;/a&gt; yesterday using Racket's &lt;a href="http://docs.racket-lang.org/reference/places.html"&gt;places&lt;/a&gt;. The coding part took about an afternoon and part of an evening. The new code is a bit less than 300 lines, most of which is boring serialization and deserialization code, some of which will go away soon.
&lt;/p&gt;
&lt;p&gt;
My database library contains two wire-protocol connection implementations (for PostgreSQL and MySQL) and two FFI-based connection implementations (for SQLite and ODBC). The wire-protocol implementations are more work, but they just use I/O ports, and Racket handles I/O pretty well. On the other hand, the entire Racket VM stops during an FFI call, because Racket threads are green threads.
&lt;/p&gt;
&lt;p&gt;
Having all threads stop execution for FFI calls isn't much of a problem if the FFI calls are all short. If the FFI call is "execute this SQL statement," on the other hand, that can cause serious problems with responsiveness. (Of course, it still depends on how long the SQL statement in question takes to execute.)
&lt;/p&gt;
&lt;p&gt;
ODBC provides the ability to execute some operations asynchronously—in theory. In practice, of all the drivers I had available on my development machines, only the DB2 driver actually supported asynchronous execution. Furthermore, the way one performs an asynchronous call—repeatedly calling a function with identical arguments until it returns something different—plays poorly with GC'd languages, where keeping memory locations identical from call to call requires more effort than it does in, say, C. In short, ODBC's asynchronous execution doesn't solve the interactivity problem.
&lt;/p&gt;
&lt;p&gt;
Racket actually has multiple kinds of concurrency. In addition to (green) threads, Racket also has "futures" (true concurrency if it's not too much trouble, everything shared) and "places" (true concurrency for sure, almost nothing shared, message passing). You can't send higher-order data (functions, objects, etc) between places (rather, you would have to be clever about it), but database connections traffic in mostly first-order data structures, so it's relatively easy to create a connection proxy that dispatches to a real database connection running in a difference place.
&lt;/p&gt;
&lt;p&gt;
The one exception, the single kind of higher-order data used by connections, is the prepared statement object. But it's possible to proxy those using a hash table and finalizers. (Actually, prepared statements use finalizers already to clean up resources, and the clean-up code is in the connection class, so I didn't even need to create a new prepared statement class.)
&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21789874-6627086331393105770?l=macrologist.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://macrologist.blogspot.com/feeds/6627086331393105770/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21789874&amp;postID=6627086331393105770' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21789874/posts/default/6627086331393105770'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21789874/posts/default/6627086331393105770'/><link rel='alternate' type='text/html' href='http://macrologist.blogspot.com/2011/08/asynchonous-execution-for-database.html' title='asynchonous execution for databases, using places'/><author><name>Ryan Culpepper</name><uri>http://www.blogger.com/profile/04275692281825651783</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21789874.post-114453331224890743</id><published>2006-04-08T15:54:00.000-06:00</published><updated>2011-09-28T03:14:39.372-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='racket'/><category scheme='http://www.blogger.com/atom/ns#' term='macros'/><title type='text'>macros, parameters; binding, and reference</title><content type='html'>&lt;p&gt;Danny Yoo had an interesting question on the plt-scheme mailing list
recently. At first it seemed like your standard non-hygienic, “I want
this to mean something in here” macro question. I used to group
macros into three levels of “hygienicness”: the hygienic ones, the
ones that are morally hygienic in that the names they introduce are
based on their input, and the totally non-hygienic ones that have a
fixed name that they stick into the program. An example of the middle
set is &lt;span class="RktSym"&gt;&lt;a href="http://docs.racket-lang.org/reference/define-struct.html#(form._((lib._racket%2Fprivate%2Fbase..rkt)._define-struct))" class="RktStxLink" pltdoc="x"&gt;define-struct&lt;/a&gt;&lt;/span&gt;, and an example of the third set is a
loop construct that binds the name &lt;span class="RktKw"&gt;yield&lt;/span&gt; in its body.&lt;/p&gt;&lt;p&gt;The third class used to offend me from a purist’s (semi-purist?)
perspective. But it’s a very reasonable thing to want to do. Consider
the &lt;span class="RktSym"&gt;&lt;a href="http://docs.racket-lang.org/reference/createclass.html#(form._((lib._racket%2Fprivate%2Fclass-internal..rkt)._class))" class="RktStxLink" pltdoc="x"&gt;class&lt;/a&gt;&lt;/span&gt; macro and the names it uses to do interesting
things: &lt;span class="RktSym"&gt;&lt;a href="http://docs.racket-lang.org/reference/createclass.html#(form._((lib._racket%2Fprivate%2Fclass-internal..rkt)._super))" class="RktStxLink" pltdoc="x"&gt;super&lt;/a&gt;&lt;/span&gt;, &lt;span class="RktSym"&gt;&lt;a href="http://docs.racket-lang.org/reference/createclass.html#(form._((lib._racket%2Fprivate%2Fclass-internal..rkt)._public))" class="RktStxLink" pltdoc="x"&gt;public&lt;/a&gt;&lt;/span&gt;, &lt;span class="RktSym"&gt;&lt;a href="http://docs.racket-lang.org/reference/createclass.html#(form._((lib._racket%2Fprivate%2Fclass-internal..rkt)._field))" class="RktStxLink" pltdoc="x"&gt;field&lt;/a&gt;&lt;/span&gt;,
&lt;span class="RktSym"&gt;&lt;a href="http://docs.racket-lang.org/reference/createclass.html#(form._((lib._racket%2Fprivate%2Fclass-internal..rkt)._init))" class="RktStxLink" pltdoc="x"&gt;init&lt;/a&gt;&lt;/span&gt;, and so on. It depends on those particular names.&lt;/p&gt;&lt;p&gt;Danny Yoo was writing a generator library. He had a
&lt;span class="RktKw"&gt;define-generator&lt;/span&gt; form, used like this:&lt;/p&gt;&lt;blockquote class="SCodeFlow"&gt;&lt;p&gt;&lt;span class="RktPn"&gt;(&lt;/span&gt;&lt;span class="RktKw"&gt;define-generator&lt;/span&gt;&lt;span class="hspace"&gt; &lt;/span&gt;&lt;span class="RktPn"&gt;(&lt;/span&gt;&lt;span class="RktVar"&gt;name&lt;/span&gt;&lt;span class="hspace"&gt; &lt;/span&gt;&lt;span class="RktPn"&gt;. &lt;/span&gt;&lt;span class="RktVar"&gt;args&lt;/span&gt;&lt;span class="RktPn"&gt;)&lt;/span&gt;&lt;span class="hspace"&gt; &lt;/span&gt;&lt;span class="RktPn"&gt;. &lt;/span&gt;&lt;span class="RktVar"&gt;body&lt;/span&gt;&lt;span class="RktPn"&gt;)&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;and he wanted &lt;span class="RktKw"&gt;yield&lt;/span&gt; to have a particular meaning inside of
the generator body. He had used the usual non-hygienic technique of
creating the right &lt;span class="RktKw"&gt;yield&lt;/span&gt; identifier using
&lt;span class="RktSym"&gt;&lt;a href="http://docs.racket-lang.org/reference/stxops.html#(def._((quote._~23~25kernel)._datum-~3esyntax))" class="RktValLink" pltdoc="x"&gt;datum-&amp;gt;syntax&lt;/a&gt;&lt;/span&gt;, but he was asking for other ideas.&lt;/p&gt;&lt;p&gt;Dave commented that non-hygienic macros typically do not play nicely
together; that is, it can be hard to write other macros that expand
into them, because you have to think about what version of the code
you want to bind the variable in, and you can’t always tell... it’s a
mess. Dave recommended creating two versions of the macro: a
non-hygienic front-end that forged the &lt;span class="RktKw"&gt;yield&lt;/span&gt; identifier, and
a hygienic back-end that did the actual implementation. People who
wanted to further abstract over generator definitions could use the
hygienic version.&lt;/p&gt;&lt;p&gt;But there’s another way to look at it, and that’s what I replied to
the mailing list. It got me thinking about the similarities between
macros and normal programming, and the different techniques we use.&lt;/p&gt;
&lt;a href="http://macrologist.blogspot.com/2006/04/macros-parameters-binding-and.html#more"&gt;Read more »&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21789874-114453331224890743?l=macrologist.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://macrologist.blogspot.com/feeds/114453331224890743/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21789874&amp;postID=114453331224890743' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21789874/posts/default/114453331224890743'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21789874/posts/default/114453331224890743'/><link rel='alternate' type='text/html' href='http://macrologist.blogspot.com/2006/04/macros-parameters-binding-and.html' title='macros, parameters; binding, and reference'/><author><name>Ryan Culpepper</name><uri>http://www.blogger.com/profile/04275692281825651783</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry></feed>
