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

H. S. Teoh hsteoh at quickfur.ath.cx
Sat Apr 11 01:11:22 UTC 2020


On Fri, Apr 10, 2020 at 05:05:45PM -0700, Walter Bright via Digitalmars-d wrote:
> On 4/10/2020 5:22 AM, Steven Schveighoffer wrote:
> > No, you don't "make" foo pure, it is specifically marked pure.
> > 
> > In other words, you have:
> > 
> > void foo(void delegate() @called) pure @nogc @safe { dg(); }
> > 
> > So the @called attribute says "foo calls dg", which means that for a
> > specific call of foo, you can strip off attributes that it doesn't
> > have.
> 
> Sorry, that's still another way of saying the same thing - foo()'s
> implementation has to be pure-compatible.
[...]

It doesn't "have to be". Nobody says foo *must* be pure.

What we're saying is that foo *can* be pure if its implementation is
pure, in which case if the delegate is pure, then calling foo with a
pure delegate will be treated as pure.  If foo is not pure to begin
with, then it will remain impure, regardless of what the delegate is.


T

-- 
Sometimes the best solution to morale problems is just to fire all of the unhappy people. -- despair.com


More information about the Digitalmars-d mailing list