What is Expressiveness in a Computer Language
Matthias Blume
find at my.address.elsewhere
Fri Jun 16 16:45:26 EDT 2006
Darren New <dnew at san.rr.com> writes:
> Matthias Blume wrote:
>> Very good statically typed versions of printf exist. See, e.g.,
>> Danvy's unparsing combinators.
>
> That seems to ignore the fact that the pattern is a string, which
> means that printf's first argument in Danvy's mechanism has to be a
> literal.
In Danvy's solution, the format argument is not a string.
> You can't read the printf format from a configuration file
> (for example) to support separate languages.
You don't need to do that if you want to support separate languages.
Moreover, reading the format string from external input is a good way
of opening your program to security attacks, since ill-formed data on
external media are then able to crash you program.
> It doesn't look like the
> version of printf that can print its arguments in an order different
> from the order provided in the argument list is supported either;
> something like "%3$d" or some such.
I am not familiar with the version of printf you are refering to, but
I am sure one could adapt Danvy's solution to support such a thing.
> Second, what's the type of the argument that printf, sprintf, fprintf,
> kprintf, etc all pass to the subroutine that actually does the
> formatting? (Called vprintf, I think?)
Obviously, a Danvy-style solution (see, e.g., the one in SML/NJ's
library) is not necessarily structured that way. I don't see the
problem with typing, though.
Matthias
More information about the Python-list
mailing list