Thursday, March 15, 2007

XMLisp

Just when you thought the XML thread (see XML-Based languages) here was going to die...

Lambda The Ultimate points us to XMLisp, an integration of XML into LISP.

I had been toying with some ideas for a humorous post here proposing that HTTP be modified to accept LISP syntax for web pages, so we could write things like


(html
(head
(meta content = "text/lhtml; charset=utf-8" http-equiv = "Content-type")
(title "JFKBits"))
(body
(h1 "A blog about languages and stuff")
))

But I quickly realized it was not as trivial as it first seemed. For one thing, I haven't attained sufficient literary control to attempt humor.

In the series on XML, we were talking about using XML and LISP syntax for representing parse trees. But XML and HTML (and SGML) are markup languages, fundamentally text marked up with semantic tags. LISP syntax is fundamentally a structure with text thrown in. Or is it?

XMLisp, which is really about integrating CLOS and XML, like an XML binding system for CLOS I *think*, does make use of integration XML syntax directly into LISP without the use of quotes:

(inspect

<HTML>

<font face="arial, sans-serif" size="-2">Small Text here</font>
<font face="arial, sans-serif" size="+2">Large Text here</font>
<a href="http://www.cs.colorado.edu">Go CU</a>

</HTML> )

It's fascinating to watch the interplay of the two simple syntaxes. They're able to take advantage of LISP syntax's minimal token list. Most XML, at least the stuff in the examples, doesn't itself include parentheses, as most other syntaxes rely on. The whitespace naturally present in the XML simply delimits which parts are atoms, and the original XML can trivially be reconstructed by inserting a single space.

2 comments:

Susan's Husband said...

It's just a difference in syntactic sugar. Both XML and Lisp (HTML, not so much) require the source to provide a clean linear version of a parse tree. As I noted in an email to you, XML based template languages are even closer because the template elements correspond much more closely to function calls.

Susan's Husband said...

Woops, forgot to note that sending the equivelant of HTML pages via a LISP style syntax is precisely how my thesis project worked, back in the days before there were web browsers.