What’s Next?

In the next chapter, you’ll look at how to implement a macro that compiles FOO expressions into Common Lisp so you can embed HTML generation code directly into your Lisp programs. You’ll also extend the FOO language to make it a bit more expressive by adding its own flavor of special operators and macros.


1In fact, it’s probably too expressive since it can also generate all sorts of output that’s not even vaguely legal HTML. Of course, that might be a feature if you need to generate HTML that’s not strictly correct to compensate for buggy Web browsers. Also, it’s common for language processors to accept programs that are syntactically correct and otherwise well formed that’ll nonetheless provoke undefined behavior when run.

2Well, almost every tag. Certain tags such as IMG and BR don’t. You’ll deal with those in the section “The Basic Evaluation Rule.”

3In the strict language of the Common Lisp standard, keyword symbols aren’t self-evaluating, though they do, in fact, evaluate to themselves. See section 3.1.2.1.3 of the language standard or HyperSpec for a brief discussion.

4The requirement to use objects that the Lisp reader knows how to read isn’t a hard-and-fast one. Since the Lisp reader is itself customizable, you could also define a new reader-level syntax for a new kind of object. But that tends to be more trouble than it’s worth.

5Another, more purely object-oriented, approach would be to define two classes, perhaps html-pretty-printer and html-raw-printer, and then define no-op methods specialized on html-raw-printer for the methods that should do stuff only when *pretty* is true. However, in this case, after defining all the no-op methods, you’d end up with more code, and then you’d have the hassle of making sure you created an instance of the right class at the right time. But in general, using polymorphism to replace conditionals is a good strategy.

6You don’t need a predicate for *inline-elements* since you only ever test for block and paragraph elements. I include the parameter here for completeness.

7While XHTML requires boolean attributes to be notated with their name as the value to indicate a true value, in HTML it’s also legal to simply include the name of the attribute with no value, for example, **<option selected>** rather than **<option selected='selected'>**. All HTML 4.0-compatible browsers should understand both forms, but some buggy browsers understand only the no-value form for certain attributes. If you need to generate HTML for such browsers, you’ll need to hack emit-attributes to emit those attributes a bit differently.