Discussion Thread: DIP 1032--Function pointers and Delegate Parameters...--Community Review Round 1

Steven Schveighoffer schveiguy at gmail.com
Mon Apr 6 12:46:02 UTC 2020


On 4/6/20 5:58 AM, Timon Gehr wrote:
> On 06.04.20 10:34, Walter Bright wrote:
>> On 4/4/2020 4:40 AM, H. S. Teoh wrote:
>>> IOW, the effective attributes of a function call is the least permissive
>>> among the function itself and its delegate arguments.
>>
>> I.e. pass a pure lambda, and the function must be pure. Like I said, 
>> that is not going to work.
> 
> The IOW is an inaccurate summary of the post, probably a typo. The 
> actual suggestion is to give it the _most_ permissive attributes.

The point is you have two sets of attributes, the declared attributes, 
and the lambda attributes. The resulting attributes for the function are 
going to be the most restrictive attributes that can call both.

i.e., if both are pure, the function is pure. If either one is not pure, 
the function is not pure.

if both are @nogc, the function is considered @nogc. If either is not 
@nogc, the function is not considered @nogc.

etc.

You need a specialized tag on the lambda/function for this to work.

This is essentially what I was proposing here: 
https://forum.dlang.org/post/r67lq7$th1$1@digitalmars.com

-Steve


More information about the Digitalmars-d mailing list