@ctfeonly

H. S. Teoh hsteoh at quickfur.ath.cx
Thu Dec 7 01:47:32 UTC 2017


On Thu, Dec 07, 2017 at 01:21:11AM +0000, Nicholas Wilson via Digitalmars-d wrote:
> I'd like to add an attribute to indicate that the annotated function
> is only available at compile time so that in cases where the operation
> is invalid at runtime (strings and concatenation on a GPU for
> instance) but the result is only used at compile time (for a mixin)
> the compiler is free to not codegen that function.
> 
> I can add this to LDC pretty easily, but does anyone else have a use
> for this (e.g. shrinking binary sizes for mixin heavy codebases) and
> would benefit having this as a standard thing?

I'd like to have this too.  Some of my template-heavy code use a good
number of CTFE-only functions that are only called at compile-time.
Since they are nested inside the template, they do quickly add up to a
lot of dead code in the executable.  Having a @ctfeonly annotation that
tells the compiler not to codegen the (many instantiations of the)
function would be greatly welcomed.


T

-- 
Let's eat some disquits while we format the biskettes.


More information about the Digitalmars-d mailing list