Bug 13568 – refactor std.format to eliminate redundant dependencies if the format string doesn't ask for it

Status
REOPENED
Severity
enhancement
Priority
P4
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-10-03T14:18:24Z
Last change time
2024-12-01T16:22:35Z
Keywords
preapproved, pull
Assigned to
No Owner
Creator
hsteoh
See also
https://issues.dlang.org/show_bug.cgi?id=3248
Moved to GitHub: phobos#10090 →

Comments

Comment #0 by hsteoh — 2014-10-03T14:18:24Z
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.
Comment #2 by hsteoh — 2017-03-17T20:45:11Z
Comment #3 by github-bugzilla — 2017-03-19T00:06:39Z
Commit pushed to master at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/4a1733e7e2e1a1b20a9e2ae2aa28fdc098dc5f7e Merge pull request #5288 from ntrel/ct-format Issue 13568: Add CT-checked format string overloads to std.format merged-on-behalf-of: Andrei Alexandrescu <[email protected]>
Comment #4 by github-bugzilla — 2017-03-22T12:22:35Z
Commit pushed to stable at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/4a1733e7e2e1a1b20a9e2ae2aa28fdc098dc5f7e Merge pull request #5288 from ntrel/ct-format
Comment #5 by github-bugzilla — 2017-03-22T22:10:40Z
Commits pushed to master at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/3aa8011a043a9bcfd52d43255f3c0a8885e143e9 Issue 13568: Add CT-checked format string overloads to std.stdio * Add overloads for readf, writef, writefln. * Separate fmt argument from args for writef[ln] to improve docs. https://github.com/dlang/phobos/commit/722683b65186a46a6f9977e15810ee766b257879 Merge pull request #5296 from ntrel/ct-stdio-format Issue 13568: Add CT-checked format string overloads to std.stdio merged-on-behalf-of: H. S. Teoh <[email protected]>
Comment #6 by github-bugzilla — 2017-04-02T21:30:39Z
Commit pushed to stable at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/95b2b139e9438e8ff7383946be4aa0de3a85159a Merge pull request #5296 from ntrel/ct-stdio-format Issue 13568: Add CT-checked format string overloads to std.stdio merged-on-behalf-of: H. S. Teoh <[email protected]>
Comment #7 by github-bugzilla — 2017-04-03T15:50:06Z
Commit pushed to master at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/95b2b139e9438e8ff7383946be4aa0de3a85159a Merge pull request #5296 from ntrel/ct-stdio-format
Comment #8 by github-bugzilla — 2017-06-17T11:34:08Z
Commits pushed to stable at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/3aa8011a043a9bcfd52d43255f3c0a8885e143e9 Issue 13568: Add CT-checked format string overloads to std.stdio https://github.com/dlang/phobos/commit/722683b65186a46a6f9977e15810ee766b257879 Merge pull request #5296 from ntrel/ct-stdio-format
Comment #9 by github-bugzilla — 2017-08-07T12:26:30Z
Commits pushed to newCTFE at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/4a1733e7e2e1a1b20a9e2ae2aa28fdc098dc5f7e Merge pull request #5288 from ntrel/ct-format https://github.com/dlang/phobos/commit/3aa8011a043a9bcfd52d43255f3c0a8885e143e9 Issue 13568: Add CT-checked format string overloads to std.stdio https://github.com/dlang/phobos/commit/722683b65186a46a6f9977e15810ee766b257879 Merge pull request #5296 from ntrel/ct-stdio-format https://github.com/dlang/phobos/commit/95b2b139e9438e8ff7383946be4aa0de3a85159a Merge pull request #5296 from ntrel/ct-stdio-format
Comment #10 by hsteoh — 2017-09-01T21:34:48Z
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
Commits pushed to dmd-cxx at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/4a1733e7e2e1a1b20a9e2ae2aa28fdc098dc5f7e Merge pull request #5288 from ntrel/ct-format https://github.com/dlang/phobos/commit/3aa8011a043a9bcfd52d43255f3c0a8885e143e9 Issue 13568: Add CT-checked format string overloads to std.stdio https://github.com/dlang/phobos/commit/722683b65186a46a6f9977e15810ee766b257879 Merge pull request #5296 from ntrel/ct-stdio-format https://github.com/dlang/phobos/commit/95b2b139e9438e8ff7383946be4aa0de3a85159a Merge pull request #5296 from ntrel/ct-stdio-format
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
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/phobos/issues/10090 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB