Completing C code with D style
forkit
forkit at gmail.com
Wed Nov 10 07:00:16 UTC 2021
On Wednesday, 10 November 2021 at 04:54:58 UTC, Stanislav Blinov
wrote:
> On Tuesday, 9 November 2021 at 11:03:09 UTC, forkit wrote:
>
>> They both produce exactly the same output.
>
> But do vastly different things.
>
>> But I tell ya.. the cognitive load .. well.. it increased
>> dramatically ;-)
>
> Of course it did. Cuz you overthunk it. Dramatically.
>
> Your D version allocates memory, for no good reason. I mean, to
> store results, but you already have storage for them, so kinda
> pointless. Your C version, OTOH, stores results on stack (so
> again, why did you allocate for them in D?..), but allocates
> some "string builder" for... what, exactly?
>
> The program is filter, or sort + partition. Requires 0
> allocations in C or D.
And.. in any case, the take away from this thread should not be
about nonallocating coding, but rather the interesting comment
from the originl op..
"Wow! your code seem so nice, I like it although I don't know how
exactly it works."
More information about the Digitalmars-d-learn
mailing list