Syntax sugar for {} with structs
Nick Treleaven
nick at geany.org
Thu Jul 7 16:24:16 UTC 2022
On Wednesday, 6 July 2022 at 15:51:56 UTC, ryuukk_ wrote:
> On Wednesday, 6 July 2022 at 14:14:09 UTC, Ogi wrote:
>>> ```D
>>> 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
Why can't you call `object.destroy()`?
> 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`)
`object.destroy` is well named, it destroys the data. If you want
to unallocate the memory, dispose is actually a better name IMO.
More information about the Digitalmars-d
mailing list