CTFE casts of delegates

Stefan Koch via Digitalmars-d digitalmars-d at puremagic.com
Tue Jan 3 01:44:38 PST 2017


On Tuesday, 3 January 2017 at 07:58:05 UTC, Eyal Lotem wrote:
> Hi,
>
> we can use an escape hatch in D to assume purity or assume 
> @nogc.
>
>
> Losing the ability to call this assertion mechanism from any 
> function that is used in CTFE context is very problematic.
>
> How can I work around this issue?
>
> Should it be considered a DMD bug? Is there any reason for 
> attribute-only delegate/function casts in CTFEe to be 
> disallowed?

The reason for them being is disallowed is, that casts are quite 
tricky at CTFE in general. Therefore everything that is not 
explicitly allowed is forbidden, also CTFE is supposed to exhibit 
no undefined behavior whatsoever.

Which is a very nice property of CTFE.

I think that I can provide a dmd patch that would allow the casts 
you want at ctfe.
However I would not propose it for inclusion myself.



More information about the Digitalmars-d mailing list