May 19, 2020
On 4/3/2020 3:39 PM, Jonathan Marler wrote:
> Instead of delegate/function pointer parameters implicitly inheriting all the attributes of the containing function, what if we made it "opt-in" with a single attribute? i.e.
> 
> @safe pure nothrow @nogc
> int foo(int delegate() @inherit dg, int function() @inherit fp)
> {
>      return dg() + fp();
> }
> 
> Advantages:
> 
> 1. No code breakage
> 2. The developer sees @inherit and knows the function/delegate pointer it will contain extra attributes inherited from somewhere else.
> 3. You can still support the case where you don't want any attributes.  Example cases of this would be if you're not calling the pointer yourself, or, maybe the function itself is nothrow but it allows the function/delegate pointers to throw and catches/handles their exceptions without propogating them.

All problems can be solved by adding another attribute. Unfortunately, this winds up with an incomprehensible "attribute soup". The idea is to try to work things out without needing extra attributes.

As mentioned in DIP1032, delegates can "opt out" by being declared with an alias type.
May 19, 2020
On 4/3/2020 3:51 PM, Jonathan Marler wrote:
> I also want to point out that the "Breaking Changes and Deprecations" section is incorrect.
> 
>     > It is possible that a parameter declaration may require that a delegate or function pointer parameter have fewer attributes than the function itself. This would only be possible if the delegate or function pointer was never called, but was ignored or simply stored elsewhere.
> 
> It's possible that you want the function or delegate pointer to have fewer attributes even when you are calling it.
> 
> In my other comment I gave the "nothrow" example, where the function itself is nothrow but the function/delegate points can throw.  So I wanted to make sure that this use case is also addressed in this section.

You are correct.


> Another use case off the top of my head is "pure".  You could be a pure function yourself, and call non-pure function/delegate pointers so long as they are inside debug blocks.

Yes again.
May 19, 2020
On 4/6/2020 11:57 PM, Piotr Mitana wrote:
> In some cases i may want to pass a @system delegate to a @safe function (or - more likely - method).

Being able to do that is addressed in #DIP1032 by declaring the delegate type separately.
1 2
Next ›   Last »