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

aberba karabutaworld at gmail.com
Wed Jul 29 10:21:11 UTC 2020


On Friday, 3 April 2020 at 10:30:33 UTC, Mike Parker wrote:
> This is the discussion thread for the first round of Community 
> Review of DIP 1032, "Function pointers and Delegate Parameters 
> Inherit Attributes from Function":
>
> https://github.com/dlang/DIPs/blob/0c99bd854302ade3e6833080410e9050fddec346/DIPs/DIP1032.md
>

I think its a good proposal.

Now about making the user of a library being able to decide 
whether to make a delegate pure or impure (as an example), I 
believe you the library author have ALREADY decided to make it 
strict so the delegate should also inherit such 
restrictiveness...most likely the ideal way to use it...as you 
intended.

But if its so that both restrictive and no-restrictive uses are 
possible as is (without extra work), then I think you have to 
weigh on which one is more ideal...which in this case is the 
restrictive. It's more like typed vs weak typed languages. 
Desiring weak type behavior comes with extra work in a typed 
language.

So having to alias the delegate is the less ideal use case (so 
its at a disadvantage to require extra work, an alias)... a 
little price to pay. Plus I personally don't see it as a big deal 
considering its not a dominant/common requirement and even it was 
a common case, you the library author has already chosen a 
desired sane default (doesn't matter the reason)...it is what it 
is.

Now do we have to explain to the user why an impure (as an 
example) delegate needs to be aliased? Probably yes. Can we not 
do that with a compiler error message?



More information about the Digitalmars-d mailing list