[Issue 5354] formatValue: range templates introduce 3 bugs related to class & struct cases

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Jan 23 14:27:41 PST 2011


http://d.puremagic.com/issues/show_bug.cgi?id=5354



--- Comment #13 from Denis Derman <denis.spir at gmail.com> 2011-01-23 14:25:33 PST ---
(In reply to comment #12)
> There are good arguments for going either way wrt the relative priority of
> toString and range interface.
> 
> Using toString by default is in a way the "right" thing to do as it's the
> default formatting for all non-range objects. For class objects, I oppose
> distinguishing between introduced toString and inherited toString; that goes
> against what inheritance is about.

Actually, my point is not about which of toString or range format should have
precedence. Rather that a programmer does defines toString in purpose: for it
to be used by builtin routines like write* functions. Ignoring it is not
acceptable. Moreover, there is no reason that a _default_ format fits specific
needs.

About toString issues such as memory usage, I do agree. They are planned to be
solved with writeTo. Then, writeTo defined by the programmer should be used for
any kind of object output, just like currently toString should be used when
defined.

Finally, as explained above, letting range default format shortcut custom
toString does not permit outputting any range which ElementType is itself.
(infinite loop bug)

Denis

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list