On Tue, Mar 29, 2011 at 4:43 PM, B Smith-Mannschott wrote:
> Horrible hack, maybe, but it got me thinking. What you seem to be
> doing is moving between "code" and "literal" mode by quoting with #.
> This is a little like traditional quasi-quote...
>
> And that got me thinking about Scribble [1] again.  In this
> context I think of scribble as being sort of an inverse of normal
> scheme syntax.  In the end, the scribble reader produces the same
> kind of data structures as the normal scheme reader, but the
> emphasis is moved from code to textual content. Source is content
> by default, but you can escape into logic.

This is kind of a good summary of the reader's intended use, beyond
our documentation system: it's fitting for any kind of code that deals
with a lot of textual content -- and having a kind of cheap DSLs for
interacting with other tools by generating source is exactly one of
the things that you can do with it.  But getting that from the
scribble documentation will be a little hard -- I wrote a paper on
just the implementation and use cases of the reader that will be much
more fitting in this context, with some examples of such uses:
  http://barzilay.org/misc/scribble-reader.pdf


On Mar 29, 7:56 pm, Ken Wesson <kwess...@gmail.com> wrote:
> TeX and LaTeX work that way, too. And in a certain sense so does
> syntax quote in Clojure itself, where the macro expansion source is
> the "content" and unquoted expressions can fill bits in by "escaping
> into logic".

Yes for TeX and LaTeX, but that's obfuscated by the programming model
that makes it necessary (since macros "call" other macros by producing
text with those macros).  But IIUC, Clojure uses a traditional
lisp-like quote mechanism, and Scribble is different from that in an
important way.  The problem with quasiquotes is that you need to be
aware of the context where code is written -- you need to explicitly
unquote code that is intended to run, and that's hard and error prone.
(My favorite example is an old version of the PLT Scheme pages that
had lots of "<quote>nbsp</quote>"s because 'nbsp was used in a context
that was already quoted.)  In contrast, the Scribble reader's approach
is that all scribble forms are, in a sense, "unquoted".  This wouldn't
be as convenient for the kind of lispish code generation that you do
with quasiquotes -- roughly speaking, you'd need to quote each head
form that is intended to produce code -- but it's extremely convenient
for dealing with text.  (This is actually based on a way of reflecting
logical terms in a theorem prover I worked on...)

In any case, that reader paper describes all the decisions that lead
to this design, and how it works in providing a better facility than
here-strings and string-interpolation, with lots of examples.  (And in
case it wasn't clear -- I strongly believe that this kind of syntax is
useful in any language, but much more in lispish languages since they
already enjoy the huge benefits of a uniform representation of
sexprs.)

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to