Languages for servers (Go, D, and more)
Dicebot via Digitalmars-d
digitalmars-d at puremagic.com
Sat Jul 5 09:28:12 PDT 2014
On Friday, 4 July 2014 at 21:15:00 UTC, Chris Cain wrote:
> On Friday, 4 July 2014 at 21:09:05 UTC, Remo wrote:
>> By "C++ style memory management" I do not mean naked
>> new/delete or malloc/free.
>> What I mean is RAII, smart pointers and destructor's.
>> What is the proper replacement for std::unique_ptr and
>> std::shared_ptr in D2 ?
>> Of course with move support for unique_ptr :)
>
> Ah, I see what you mean now. D has that:
>
> http://dlang.org/phobos/std_typecons.html#.Unique
> http://dlang.org/phobos/std_typecons.html#.RefCounted
>
> But they probably need some decent updating for use with @nogc
> and more modern D style, though.
>
> Also the Unique pointer also works with std.algorithm.move (in
> addition to its "release" method which could be deprecated, I
> think... not sure why it needs it when we have
> std.algorithm.move).
This is what I have been referring to in my earlier comment.
These utilities provide RAII experience very similar to one in
C++ and work pretty good if you stick to certain style of
programming. But they are implemented by using struct wrappers
and all polymorphic traits are lost.
C++ does not have this strong distinction between structs and
classes resulting in a bit more flexible RAII application.
Writing applications in C++ style is certainly possible but may
require some rather advanced knowledge of what can and what can't
be done. @nogc helps here a lot.
More information about the Digitalmars-d
mailing list