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

Walter Bright newshound2 at digitalmars.com
Thu Jul 30 02:03:56 UTC 2020


On 7/29/2020 9:30 AM, H. S. Teoh wrote:
> the only way to achieve this is to template the code,
> which means 2^N copies of*exactly the same generated code*  where N is
> the number of attributes you'd like to support.

The right way to solve that problem is for the compiler to merge functions that 
are semantically identical, because there are a lot more instances of that than 
in this example.

Having a messy compiler feature for it is not the best.

P.S. gdc/ldc may already do this as C++ has the same issue

 > This hack is widely used in Phobos code precisely because there is
currently no way to express that "this function's purity depends on the
purity of the callback argument".

Whenever one needs to test attribute inference, you'll need such tests. There's 
also passing a function as a template alias parameter.


More information about the Digitalmars-d mailing list