Eliminating FORMAT from Lisp
cs.yale.edu/homes/dvm/format-stinks.htmlPosted Jul 26, 2007, 12:24 AM UTC
Posted Jul 26, 2007, 12:24 AM UTC
Worth reading if only for the history in the first few paragraphs.
agree.
the rest is pure eye-bleach.
printf-like functions are ugly in languages with intrinsic list and tuple support--especially dynamically typed languages--because you can easily use lists and symbols to structure the same formatting info. No need to pack everything into a string.
I do admit to liking true variable interpolation in strings, a la Perl. That's even shorter and more straightforward.
The "out" macro reminds me a little bit of Lisp markup-outputting DSLs like CL-WHO.
A straightforward application of pretty-printing combinators defining a DSL. Like it.
wow, a clear and unambiguous exposition of the degeneracy of the lisp 'mindset'.
You would probably think that the New York telephone book is a clear and unambiguous exposition of the degeneracy of the lisp mindset.
(Whereas lispers would look at the phone book and say "I bet I could parse this with cl-ppcre and stick it into a nice s-expression format! Then gzip it for space, I guess.")
parsing something with regular expressions and sticking the result into an s-expression is by far the stupidest, most error-prone and inefficient way of parsing something.
read a compiler construction book, please.
One nice thing about format-style functions is that they make i18n somewhat easier, especially if they support named or indexed replacements (like "foo: %(foo)s" or "foo: {1}", that is.)
While that may be somewhat true in other languages, in Lisp you can just store the form (or function :) that formats the string instead.
Common Lisp's FORMAT, however, has stuff that's positively anti-i18n.
Case conversion, which doesn't even make sense for some charsets; automatic pluralizing, which is useful only in English text and perhaps a few other European languages with the 's' pluralization method; built in conversion to specifically english text for numbers using ~R...
Definitely. The writer considers (out "x = " x ", y = " y ", z = " z :%) better than a format string + arguments. It's the same mistake that C++ made by overloading <<
i hate 'operator<<'.
it also managed to mess up templates for over a decade.