Getting the const-correctness of Object sorted once and for all

H. S. Teoh hsteoh at quickfur.ath.cx
Mon May 14 13:28:15 PDT 2012


On Mon, May 14, 2012 at 11:55:15PM +0400, Dmitry Olshansky wrote:
> On 14.05.2012 23:26, Steven Schveighoffer wrote:
[...]
> >Oh, and also, we should fix that problem (that writef allocates).
> >However, I think we need DIP9 in order to do that.
> >http://prowiki.org/wiki4d/wiki.cgi?LanguageDevel/DIPs/DIP9
> >
> 
> DIP9 for the win!
> I tried to revive at least *some* interest in it for a long time.
[...]

+1.

I like this proposal. I have never liked the idea of toString() ever
since Java introduced it.  Besides memory usage issues, toString() also
binds you to the string type for no good reason: what if you wanted to
store the result into a database file? Why waste resources on an
intermediate representation if it can be written straight to its final
destination?

I'd even argue that DIP9 is an excellent example of:

http://en.wikipedia.org/wiki/Dependency_inversion_principle

We don't know what representation the caller ultimately wants (string in
memory, file on disk, network socket, etc.), so why impose an
essentially arbitrary concrete representation type? Let the delegate
decide what to do with the data.


T

-- 
Just because you survived after you did it, doesn't mean it wasn't stupid!


More information about the Digitalmars-d mailing list