| Richard P. Gabriel (one of the co-creators of Common Lisp, later a founder of the Lisp vendor, Lucid) has a few interesting things to say about CL's FORMAT in his Patterns Of Software, starting on page 101: https://www.dreamsongs.com/Files/PatternsOfSoftware.pdf > What are the trade-offs? Format strings don’t look like Lisp, and they constitute a non-Lispy language embedded in Lisp. This isn’t elegant. But, the benefit of this is compact encoding in such a way that the structure of the fill-in-the-blank text is apparent and not the control structure. IMO McDermott's OUT macro has precisely the drawbacks Gabriel predicts. While McDermott seems to think it's an advantage that > we no longer have to squeeze the output data into a form intelligible to format, because we can use any Lisp control structure we like his example PRINT-XAPPING basically duplicates the logic for extracting data from the xapping structure as Steele's FORMAT call, but buries the data extraction into control structure alongside constant strings that go into the output. And that's where I think FORMAT really a win: a FORMAT control deliberately separates the control flow and constant text from the data extraction logic. Presumably you could write functions that do the same thing using McDermott's OUT macro, but they'll be more verbose and no more enlightening; what's the point? |
I think there is some advantage to allowing comments to be nested alongside the relevant bits of format text.
It reminds me a bit of Perl's /x modifier[1], which arguably achieves some of the best of both worlds for regex expressions.
[1] https://perldoc.perl.org/perlre#/x-and-/xx