pure-ifying my code

Daniel Davidson nospam at spam.com
Mon Nov 18 10:16:11 PST 2013


On Sunday, 17 November 2013 at 10:56:16 UTC, Jonathan M Davis 
wrote:
>
> I think that the typical approach at this point is to just drop 
> purity for the
> moment, but if you want you really want it, you are indeed 
> going to have to
> implement it yourself. But we'll get there with Phobos 
> eventually. The primary
> holdup is some compiler improvements, and we'll get them. It's 
> just a question
> of when.
>
> - Jonathan M Davis

Why is it that compiler improvements are the holdup? Honest 
question. Is it more that the approach taken for the specific 
implementation went beyond the capabilities of the compiler at 
the time (like its inferencing capabilities)? Maybe purity was 
not a focus at the time of writing a lot of phobos and there are 
not loads of testing on it where purity was a factor. If so, 
isn't an alternative implementation now an improvement over 
waiting for the compiler updates. A corollary question would be 
are the benefits of Voldermort types in phobos worth the purity 
issues they cause?

 From this article 
(http://www.drdobbs.com/cpp/voldemort-types-in-d/232901591) 
Walter says, regarding the pre-Voldermort version of 
RandomNumberGenerator:

"I could mark it with the private attribute and modules other 
than rnd won't be able to access it. But it's still there, 
outside the scope of where it belongs, and other module members 
can still access it, private or not (in D, private declarations 
are not hidden from other declarations within the same module). 
Besides, I want it to be so clean it squeaks."

Noble goal - maybe. But maybe not as noble as users' efforts to 
realize benefits of purity now. Purity/const/immutable when 
broken spread virally.

Thanks
Dan


More information about the Digitalmars-d-learn mailing list