Feedback Thread: DIP 1032--Function pointers and Delegate Parameters...--Community Review Round 1
Walter Bright
newshound2 at digitalmars.com
Fri Apr 3 21:13:10 UTC 2020
On 4/3/2020 7:01 AM, Steven Schveighoffer wrote:
> On 4/3/20 9:08 AM, Steven Schveighoffer wrote:
>> T foo(T)(T delegate() dg, T function()) { return dg() + fp(); }
>
> I should clarify this.
>
> Since the delegates are provided not as template parameters but with a templated
> return value, the attributes can be inferred as normal. So this actually isn't
> an issue.
>
> It's more when the template doesn't actually call the delegate or function, e.g.:
>
> struct S(T)
> {
> T delegate() _dg;
> void foo(T delegate() dg) { _dg = dg; }
> }
>
> foo can be inferred as @safe, @nogc, nothrow, pure. What happens to dg?
>
> -Steve
Delegate/functionpointer parameters do not infer safe/nogc/pure/nothrow from
their use inside the function. They don't do it now, and the dip does not
suggest changing that.
More information about the Digitalmars-d
mailing list