Currently, std.format.formattedWrite (along with the convenience wrappers around it, namely writef, writefln, std.string.format, etc.), take a runtime format string as argument, although most use cases involve format strings that are already known at compile-time. This limits what we can statically do with these string, e.g., statically check that the right number of arguments are being passed for that format, that the right types are being passed, etc., instead of deferring until runtime to detect any problems.
Ideally, we should extend formattedWrite() to accept compile-time strings so that if the format is already statically known, we can perform compile-time checks on it.
Comment #1 by hsteoh — 2014-11-21T03:39:56Z
Another major advantage of compile-time format strings is that we can avoid format() pulling in half of Phobos on the off-chance that some obscure runtime format string might actually need that code to format something. By analysing the format string at compile-time, we can make it so that only the necessary bits of code are imported, thus greatly clearing up the big hairball that is Phobos module interdependencies currently.
This is not completely fixed yet. Part II is to refactor std.format to eliminate redundant dependencies if the format string doesn't ask for it. E.g., if the format string is only "%s" the resulting code should not pull in dependencies on floating-point formatting code.
Comment #11 by b2.temp — 2017-09-27T22:59:39Z
There's https://issues.dlang.org/show_bug.cgi?id=17381 that could be handled the day std.format will be refact.
The strategy used to check statically the specifier (call format() and look if there's been an exception) makes it impossible to fix.
Comment #12 by github-bugzilla — 2018-01-05T13:27:54Z
Comment #13 by greensunny12 — 2018-03-30T01:05:29Z
> This is not completely fixed yet. Part II is to refactor std.format to eliminate redundant dependencies if the format string doesn't ask for it
This should have been a separate issue (bugzilla even allows meta issues that depend on other issues), but I renamed this for now.
Comment #14 by robert.schadek — 2024-12-01T16:22:35Z