GC/nogc status in docs

Harry Gillanders contact at harrygillanders.com
Mon Jul 13 19:59:19 UTC 2020


On Monday, 13 July 2020 at 18:14:56 UTC, Ogi wrote:
> On Thursday, 9 July 2020 at 12:55:45 UTC, aberba wrote:
>> Has there been any consideration on tagging Phobos function as 
>> either GC or no-GC depending on how they behave for general 
>> awareness when reading the docs?
>>
>> I'm thinking it could be useful to know what you get.
>
> I wonder how much of Phobos is not @nogc simply because of the 
> use of exceptions. Walter had some ideas that would allow 
> exceptions to work without GC. Is there any progress?


-dip1008 seems to work well enough.

But even when compiling with -dip1008, many exceptions in Phobos 
allocate a message string via the GC.
Moreover, many functions in std.exception rely on `lazy` 
parameters, which can't be inferred as @nogc, so any Phobos 
functions that use something like `enforce`, or `ifThrown` aren't 
@nogc.

See this example of something trivial which won't compile as 
@nogc even with -dip1008:

	import std.exception;

	void main () @nogc
	{
		int x = 5;

		enforce(x <= 4);
	}



More information about the Digitalmars-d mailing list