Bug 24713 – `to!string` and `format` don’t handle infinite ranges

Status
NEW
Severity
enhancement
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2024-08-21T13:09:02Z
Last change time
2024-12-01T16:42:54Z
Assigned to
No Owner
Creator
Georgy Markov
Moved to GitHub: phobos#10559 →

Comments

Comment #0 by ogion.art — 2024-08-21T13:09:02Z
It is desirable to be able to stringize all existing D types (with `noreturn` being exception). Currently, this doesn’t even compile: import std.range, std.conv; void main() { auto s = 42.repeat.to!string; } > Error: none of the overloads of template `std.conv.toImpl` > are callable using argument types `!(string)(Repeat!int)` And this compiles but gets stuck in an infinite loop: import std.range, std.format; void main() { auto s = format("%s", 42.repeat); } An infinite range could be denoted by printing its first three elements followed by an ellipsis (in this case: "[42, 42, 42, ...]").
Comment #1 by robert.schadek — 2024-12-01T16:42:54Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/phobos/issues/10559 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB