I want to add a Phobos module with template mixins for common idioms.
Jonathan M Davis
jmdavisProg at gmx.com
Fri May 24 16:18:24 PDT 2013
On Saturday, May 25, 2013 00:08:37 Dmitry Olshansky wrote:
> 24-May-2013 22:13, Jonathan M Davis пишет:
> > Lacking a proper language solution, we could create something similar to
> > Rebindable but for shared.
>
> Then in my vision built-in OOP has failed if we need at least 2 wrapper
> types implemented as structs on top of built-in refs. Then recall (to be
> implemented) RefCounted!ClassType and we have yet another library land
> solution to make OOP types with ref-counting.
>
> On occasion I've been enumerating the amount of special casing class
> references require and truth be told I fail to see the benefit of having
> them as built-in outweigh the cost. With multiple alias this I could
> have implemented the OOP in library just fine as Ref!T struct. Then
> Ref!(const(T)) is ConstRef!T
> Ref!(shared(T)) is SharedRef!T
>
> And now UDAs can serve for override/virtual, inheritance etc.
Overall, I think that OOP in D works fine, but we have some definite issues with
const due to how Object is currently set up, and the fact that the type system
can't distinguish between a reference to a class object and the class object
itself is definitely annoying, and I have no idea why it works that way (though
my guess would be that it's simply the side effect of making it so that they
have to live on the heap). We would definitely be better off if we could fix
that. I do think that the remaining issues with OOP in D are quite fixable
though. It just takes time and effort, and doing stuff like removing
unnecessary functions from Object are probably blocked by the AA mess. So, we
definitely have problems, but they're not insurmountable.
On the other hand, with regards to this particular problem, as Walter inquires
in the bug report for not being able to have local references to shared
objects, I have no idea what the use case for such would even be.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list