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

Mathias LANG geod24 at gmail.com
Wed Jul 29 04:59:46 UTC 2020


On Wednesday, 29 July 2020 at 04:45:07 UTC, H. S. Teoh wrote:
> On Tue, Jul 28, 2020 at 06:21:44PM -0700, Walter Bright via 
> Digitalmars-d wrote:
>
> In that case, what about extending inout to attributes besides 
> const? I don't know what's a good syntax for it, maybe 
> something like inout(pure), for lack of a better idea, to 
> indicate conditional purity?
>
> It's basically the same idea as inout: as far as the function 
> body is concerned, it's pure (resp. const); but to the caller, 
> it could be pure or impure (resp. immutable/mutable) depending 
> on what was passed in. I argue that this would be much more 
> useful than what this DIP proposes.
>
>
> T

I strongly agree with this (as mentioned in this thread and the 
Github PR already).
I agree with Walter that silently removing attributes is bad. The 
compiler should error if the body tries to do something that 
violates the attributes of the function.
What we want is the ability to say "This function is ${QUAL} if 
this ${CALLABLE} is ${QUAL}" where QUAL is one or more attributes 
among (pure, at safe,nothrow, at nogc) and CALLABLE is a delegate or a 
function pointer.


More information about the Digitalmars-d mailing list