Generic memory allocation in D

Richard (Rikki) Andrew Cattermole richard at cattermole.co.nz
Tue Mar 5 03:39:41 UTC 2024


On 05/03/2024 4:29 PM, Walter Bright wrote:
> On 3/4/2024 12:38 PM, Paul Backus wrote:
>> For example, you have this:
>>
>>      // true means success
>>      if (f.isPure())
>>          // it's pure
>>      else
>>          // it's impure
>>
>> ...but also this:
>>
>>      // true means failure
>>      if (f.checkPurity(loc, sc))
>>          // it's impure
>>      else
>>          // it's pure
> 
> I know there are inconsistencies in the DMD code base. It shows the 
> effects of many people working on it over decades.
> 
> However, "isPure" asks a question. "checkPurity" does not, and so it 
> isn't implicit how the logic should go.

s/checkPurity/isFunctionCallableWrtPurity/

A much longer name, but now the purpose is very clear what it does.

True for success, false for failure.

Based upon my understanding of its body it looks like this is a valid 
name/behavior.

https://github.com/dlang/dmd/blob/95ba36a3fdd46850666aaebf2db31dd7c5dc9012/compiler/src/dmd/expressionsem.d#L1860


More information about the Digitalmars-d mailing list