On Monday, 18 November 2013 at 19:52:42 UTC, Jonathan M Davis wrote:
On Monday, November 18, 2013 19:16:11 Daniel Davidson wrote:
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.

Attribute inferrence was added to the language specifically in order to make it possible for pure, nothrow, and @safe to work with templates and therefore make it possible to use them with Phobos. Without it, they don't, because you're stuck either requiring a specific set of attributes (limiting what the templates work with) or duplicating the templates with different combinations of attributes. We got enough attribute inferrence to reduce the problem, but the feature has yet to be implemented enough to fully fix the problem. It's compiler improvements which made using pure with std.algorithm possible at
all.

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?

Voldemort types are just part of the problem. Attribute inferrence is just plain too primitive right now, and really needs to be improved. The problem is
reduced if you don't used Voldemort types, but it's not fixed.

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

It's also the case that none of that has ever worked with pure, so we haven't lost anything. We just haven't yet gained what we should have gained. But the push really needs to be to improve the compiler IMHO, because without that, attribute inferrence in general just isn't going to be good enough, and if Phobos' current situation highlights how poor the attribute inferrence is, all
the better, because that puts more pressure on getting it fixed.

Some of the newer functions have not used Voldemort types in order to fix similar problems, but I don't think that it's worth going and changing them all just to work around a problem with the compiler. The compiler needs to be fixed. At best, what you're talking about doing is contorting Phobos' implementation in order to make it work better with the half-implemented feature of attribute inferrence, but since it's that feature that makes it possible at all, and it really needs to be fully implemented regardless, it makes by far the most sense IMHO to just finish implementing it. But when that happens is up to the compiler devs, and at this point, I'm a library dev, not
a compiler dev.

- Jonathan M Davis


I opened a new pull request to fix the compiler issue.

https://github.com/D-Programming-Language/dmd/pull/2832

Kenji Hara

Reply via email to