Refactoring a "simple" function in dmd source

Walter Bright newshound2 at digitalmars.com
Sun Dec 31 19:09:15 UTC 2023


On 12/31/2023 5:02 AM, Siarhei Siamashka wrote:
> Or more like https://dlang.org/library/std/string/line_splitter.html for having 
> no allocations and `@nogc` compatibility.

I missed the existence of that. Oops!

> The listed benefits are nice and very much welcome, but it's a copy-paste job 
> from Phobos into the DMD codebase. Raising a question again about the reasons 
> why DMD itself isn't using Phobos like any normal applications do.

It's good to question decisions now and then, but we just had a conversation 
about it.

> Also whenever game developers are complaining in this forum about poor `@nogc` 
> support, they are being told that the GC is totally fine and they are just 
> unreasonably biased against it. All of this while the DMD compiler itself is 
> doing fancy hackish stunts with memory allocation. Games are latency sensitive. 
> Compilers are not.

GC is just another tool. There are places where it is appropriate, and places 
where it is not. Because some functions in Phobos use GC does not mean anyone 
using Phobos must use GC, not at all.

Problems also exist if Phobos was to use malloc(). In particular, who owns the 
memory thus allocated?

Finding a method that avoids allocation entirely resolves this conundrum rather 
neatly.


More information about the Digitalmars-d mailing list