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

Walter Bright newshound2 at digitalmars.com
Mon Apr 6 21:11:31 UTC 2020


On 4/6/2020 5:46 AM, Steven Schveighoffer wrote:
> 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.

That's more or less what the DIP proposes. The delegate parameter defaults to 
being at least as restrictive as the function it is declared in. The delegate 
parameter can be made more restrictive by adding attributes to it directly.

To make the delegate parameter less restrictive, it would need to be declared 
using an alias for the type, as shown in the DIP.

The point of this is so that the function can call the delegate, which is far 
and away the usual use case. The unusual use case is storing the delegate 
somewhere else for someone else to call.

The DIP does not propose that the delegate parameter infer its attributes based 
on the function's body. To implement that would require an iterative approach, 
and that is not worth the complexity.


More information about the Digitalmars-d mailing list