On Wednesday, 6 July 2022 at 14:14:09 UTC, Ogi wrote:
> On Friday, 1 July 2022 at 11:51:57 UTC, ryuukk_ wrote:
> I had to write this recently
void reset()
{
state.end_index = 0;
state.buffer_list = SinglyLinkedList!(ubyte[])();
}
While not that bad, it's annoying, why can't we do like like: A a = {}
?
void reset()
{
state.end_index = 0;
state.buffer_list = {};
}
Um, what’s wrong with destroy
? It resets any variable to initial state (and calls its destructor). Isn’t it what you need?
I don't use RAII, destroy does something very specific in my arena allocator
The problem i have with destroy
is that it is a global and universal function that accepts anything
It should be either internal, reserved with a prefix, moved to a module, or removed
D likes to steal common words that i can't use in my APIs
debug
, version
, init
, destroy
It forces me to come up with annoying alternatives
dbg
, versionn
, create
, dispose
(but i really need destroy
)
This is poor design in my opinion