On Tuesday, 11 April 2017 at 21:06:28 UTC, Jack Stouffer wrote:
On Tuesday, 11 April 2017 at 20:48:13 UTC, Piotr Kowalski wrote:
Is it in std already? How do I allocate equivalent of
std::vector on heap with RAII in D that will be disposed at
the end of the scope automatically?
You're asking about two different things here.
RAII is already in the language. As soon as a struct exits its
scope, its destructor is called.
Specifically for a vector type with elements allocated on the
heap that is destroyed on scope exit, I would look at
https://dlang.org/phobos/std_container_array.html
If you want a more performant version that is integrated with
std.experimental.allocator, then I would look at
https://github.com/economicmodeling/containers
Ok, maybe I was too specific, I wanted to ask what is the current
support of RAII in whole std while using @nogc, not in the
language itself.
I worked on that [0] and decided its not worth it. It is
literally a "game". You can have > some fun tuning benchmark
programs. You should not let it influence your decision making.
It's all about perception, if you don't know that something
exists or is capable of doing something then you will never
choose it. Sure it's a benchmarking game, but game people refer
to a lot on reddit or hn. And people still think D is slow so
they don't even consider using it. It's really about marketing.