4 ms·
> 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'
by interroboink 4y ago
> 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 https://perldoc.perl.org/perlre#/x-and-/xx
- lapsed_lisper 4y agoDoes it really make that much difference if comments exist "inside" the embedded sublanguage vs. "outside"? After all, you can always construct a format specification by string concatenation, and in CL, you can trick the parser into doing this for you: (format stream t #.(concatenate 'string ;; comment about the first piece <piece 1> ;; comment about the second piece <piece 2>) ...) Additionally, for the record, CL's FORMAT is sufficiently hairy that you can achieve the effect of in-band comments if you wanted to: (format t "~ ~0{ Because the previous line ended with a tilde, the following newline is ignored. All of this text occurs inside an iteration construct that loops zero times, so will not be output. However, it will consume one element from the list of arguments, so after this loop, we'll use tilde-colon-asterisk to back up one element, and let what comes next decide how to format it. So this is more or less a comment inside a CL FORMAT string. ~}~:*~ ~S" 'Foo)