DIP: @mustuse as function return value annotation

Richard (Rikki) Andrew Cattermole richard at cattermole.co.nz
Mon Aug 12 08:35:19 UTC 2024


On 12/08/2024 8:29 PM, mw wrote:
> On Monday, 12 August 2024 at 08:11:58 UTC, Richard (Rikki) Andrew 
> Cattermole wrote:
>> On 12/08/2024 8:09 PM, mw wrote:
>>> I have no idea how the current D's compilation model works.
>>>
>>> To implement what is proposed above, I assume there is only one 
>>> global ASTree (singleton) of all the source files (even in the 
>>> context of separate compilation of each D source file), which holds 
>>> all the calculated annotation from different compilation passes, and 
>>> the @mustuse checker is invoked after all the annotations are fully 
>>> calculated.
>>
>> That works for one process invocation.
>>
>> But D is multi-process invocation.
>>
>> A process is built by multiple compiler executions and do not share 
>> this knowledge.
>>
>> This information simply wouldn't exist for later stages of compilation.
> 
> Can we write the ASTree to temporary files, or a daemon process? so the 
> calculated global annotation can be shared by later compilation process.

This has been discussed a lot of times in the past including for the 
benefit to performance.

Also no, we cannot use a daemon process for this. The multiple compiler 
invocations may not be on the same machine, or started by the same person.

Unfortunately the only option is to either disallow adding it to 
classes, or disallow casting upwards, I am unaware of any other solution 
to this.



More information about the dip.ideas mailing list