Coming back, Unique, opDot and whatever else

Jacob Carlborg doob at me.com
Sat Jan 18 03:00:44 PST 2014


On 2014-01-17 21:25, Stanislav Blinov wrote:

> Ahem. Wasn't it what I said? :)

I don't know, perhaps I missed that :)

> Of course I did try. My concern is that
> it would stop accepting arbitrary user types. Most times this would be a
> good thing. But not always. Hence I'm hesitating :)

Right, but the opposite could be said as well. If it's not marked with 
@safe no other functions marked with @safe can call the function. But 
any non-safe function can call @safe functions.

> Oh, I didn't say so, but of course once they're out of class, they're
> bound to have proper names. I don't know if you've caught that comment
> in the code, but I basically intentionally named them ugly to minimize
> collisions.

I didn't think of that. Perhaps using two underscores instead then, 
since the compiler is has reserved those names no one else should use 
them. I think this is an edge case where this could be allowed.

Alternatively, as you wrote in a comment, use free functions. Since they 
would be declared in the same module they would have access to the 
private data. Hmm, but the compiler prefers opDispatch before UFCS.

> Heh, now I'm even more leaning towards a proxy. Because honestly,
> x.opDispatch!("release")() is even uglier than x.opDot().release() :D By
> proxy I mean replacing opDot() with a mixin that would directly inject a
> Unique with an interface of a wrapped object. That has some problems
> (like how to forward calls to template functions), but hey, I'm
> experimenting here!

Does opDot even work?

-- 
/Jacob Carlborg


More information about the Digitalmars-d-announce mailing list