3 ms·
Well the point is that it could have been an actual macro instead of a function that processes a syntactical-opaque control string. I do appreciate the conveni
by nerdponx 4y ago
Well the point is that it could have been an actual macro instead of a function that processes a syntactical-opaque control string.
I do appreciate the convenience and brevity of FORMAT as it currently exists, but I also think it would be pretty cool to have a proper S-expression macro that expands to a FORMAT control string. It would be analogous to a macro that generates SQL or HTML.
- aidenn0 4y agoIt can't be a macro without requiring the string to be constant.
- nerdponx 4y agoThat's what I had in mind, which covers most use cases of FORMAT that I've seen.
- kazinator 4y agoCommon Lisp provides an explicit macro for this called formatter. The macro produces a function. The format function allows a functional argument in place of the format string for this reason. (format t (formatter "~a-~b") x y) is like (format t "~a-~b" x y) except that "~a-~b" is transformed into a lambda which takes a stream and two arguments, and which does the specified formatting.
- nerdponx 4y agoThere are so many corners of the spec that I have not yet explored, so I always appreciate trivia like this. However I was thinking more like the macro that the article was proposing.