Syntax sugar for {} with structs

ryuukk_ ryuukk.dev at gmail.com
Fri Jul 1 17:33:55 UTC 2022


On Friday, 1 July 2022 at 15:55:50 UTC, Paul Backus wrote:
> On Friday, 1 July 2022 at 11:51:57 UTC, ryuukk_ wrote:
>> Maybe it could be a syntax sugar for `state.buffer_list = 
>> state.buffer_list.init`
>
> Simple enough to write a utility function that does this:
>
> ```d
> void reset(T)(ref T obj)
> {
>     obj = typeof(obj).init;
> }
> ```
>
> Now you can write `reset(state.buffer_list)` (or 
> `state.buffer_list.reset` if you prefer). No need to repeat 
> yourself.

We have to stop with utility function to solve annoyances like 
this

I'd use an other language if i have to keep writing utility 
functions and templates all over the place and keep importing ton 
of modules because the language refuses to evolve paste the 80's


More information about the Digitalmars-d mailing list