Coming back, Unique, opDot and whatever else

qznc qznc at web.de
Thu Jan 16 22:25:51 PST 2014


On Friday, 17 January 2014 at 01:12:04 UTC, Stanislav Blinov 
wrote:
> Hello everyone! It's been a long time since I last posted here, 
> I've been away from all things D, only being able to take an 
> occasional peek from time to time. It's so good to be back. I'm 
> now finding a bit of time to commit to learn D, more relearn as 
> it would seem.
>
> I've started my rediscoveries with exploring of concurrency, 
> parallelism, threading in D, and after some time I found myself 
> thinking "I need a unique encapsulator". Don't ask why, I may 
> not even be able to answer it in a month. But that helped me 
> solve some problems before in C++, so I thought why not try it 
> here? In a couple of page views I came upon std.typecons and 
> its Unique type. And I thought "why that is exactly what I 
> want!". And it was, too. But after taking a closer look at its 
> general implementation I just couldn't help myself but think 
> "well, it seems it was done in a hurry, never finished, left as 
> it was because this of that and whatnot". I mean, those sparse 
> comments, things like "doesn't work yet", etc... I thought 
> well, since I'm learning the language again, why not make it an 
> exercise and fill those blanks? It'd certainly help me, because 
> it would improve the abstraction I'm using, and because it's a 
> learning experience.
>
> So, here's what I came up with for now:
>
> http://codepad.org/S4TfIdxc
>
> Granted, not a complete implementation, keeping not very far 
> from the original. But right now I think it's a good time to 
> ask you guys what do you think? Where have I went wrong, what 
> did I do incorrectly, what potential issues can you spot in 
> this? I mean, I'm not asking about using opDot(), which, as I 
> understand it, could be going away anytime now. At least I 
> think I managed to fill in most of the "blanks" of the current 
> implementation while keeping (almost?) to the same interface.

Improving Phobos code by filling in the blanks is usually a good 
idea and a good learning experience as well.

Changing an interface in Phobos is a big deal and should be 
thoroughly justified. Does it break backwards compatibility? Why 
is it necessary?

(btw moving to .learn is not possible, unfortunately)


More information about the Digitalmars-d-announce mailing list