Bug 5130 – writeln cannot take delegate

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2010-10-29T08:42:00Z
Last change time
2013-01-01T10:27:29Z
Assigned to
nobody
Creator
zan77137

Comments

Comment #0 by zan77137 — 2010-10-29T08:42:46Z
writeln, format, Tuple(T).toString and so on cannot take delegate(in trunk r2116). This code should compile: ---- import std.stdio; void main() { writeln({}); } ---- This bug occurred recently. On dmd 2.042, this bug doesn't occur. http://ideone.com/iXHoB
Comment #1 by andrei — 2011-01-04T09:43:05Z
I wonder if printing the type of the delegate is the smartest thing to do. After all one can always print typeid(...) if that's what's needed.
Comment #2 by zan77137 — 2011-01-05T07:00:52Z
(In reply to comment #1) > I wonder if printing the type of the delegate is the smartest thing to do. > After all one can always print typeid(...) if that's what's needed. I think so, too. However, there is a problem in Tuple. Because Tuple struct was not able to receive delegate for toString function, I made it printable as first aid. As well as Tuple, a problem may occur. Range, container, assert message... It may be that you had better offer the default print method to support the generic programming.
Comment #3 by lovelydear — 2012-04-21T16:04:10Z
2.059: PS E:\DigitalMars\dmd2\samples> rdmd bug.d 402020
Comment #4 by lovelydear — 2012-12-31T12:37:33Z
Checked on 3 compilers, it compiles and runs. This one should be closed, I guess.