Implicit conversions through purity

Jonathan M Davis jmdavisProg at gmx.com
Mon Apr 14 03:37:18 PDT 2014


On Sunday, April 13, 2014 01:52:13 bearophile wrote:
> Jonathan M Davis:
> > Honestly, I would have considered that to be a bug. Converting
> > the return type
> > to a different level of mutability based on purity is one
> > thing. Automatically
> > casting the return value just because the function is pure is
> > another matter
> > entirely. Clearly, it can work, but it seems incredibly sloppy
> > to me.
> 
> In foo1 D is working as designed, as this was a desired feature,
> it has passed the Kenji and Walter review, and it was implemented
> several months ago. It's a very handy way to create immutable
> data with pure functions and it's safe, it's safer than
> assumeUnique that is just a convention. Very recently Walter has
> further improved this feature, allowing more implicit conversion
> cases. So it's the opposite of a bug, it saves you from bugs in
> three different ways.

Well, it's the first I've heard of it, and I certainly don't like the idea, 
but if it's intended and implemented, then that's the way it is, I guess. 
Maybe I'll come to agree after thinking about it more.

> But my question was about the successive foo functions :-)

Well, if I don't like the first example, I'm not about to be in favor of 
making more examples follow suite.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list