named arguments, string interpolation, please stop.
Timon Gehr
timon.gehr at gmx.ch
Thu Jan 11 21:32:58 UTC 2024
On 1/11/24 22:06, Dennis wrote:
> On Thursday, 11 January 2024 at 20:55:52 UTC, Timon Gehr wrote:
>> On 1/11/24 20:33, Walter Bright wrote:
>> Maybe you want to avoid implicit GC allocations in some part of the
>> code, but now you have to mark the entire function `@nogc` to get the
>> checking, and then you can no longer use exceptions in that function.
>>
>> etc.
>
> Considering the compiler doesn't use @nogc for anything that matters
> (unlike nothrow, which changes code generation), I wonder if we could
> degrade @nogc from a type attribute to a linting tool. It would still
> point out accidental array literals or closures, but not complain when
> calling a function that hasn't been proven to be @nogc.
> ...
Maybe, but sometimes you really don't want any allocations, as they
would lead to a memory leak. The exception case in this example is
special exactly because of its implications on control flow.
> It can still complain when calling a function that has been inferred
> @gc,
Well, but then I can't allocate an exception again.
> and if you want to be GC free 100% certain, don't link it and the
> linker will complain about missing symbols.
Personally, I want to use GC, perhaps just not in the innermost loop
performing latency-critical operations behind a `GC.disable()` and not
for the sole reason that the compiler's escape analysis was overly
conservative.
More information about the Digitalmars-d
mailing list