@ctfeonly
Nicholas Wilson
iamthewilsonator at hotmail.com
Fri Dec 8 11:48:26 UTC 2017
On Friday, 8 December 2017 at 10:46:20 UTC, John Colvin wrote:
> On Thursday, 7 December 2017 at 01:21:11 UTC, Nicholas Wilson
> 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?
>
> How would such a thing interact with __traits(compiles, ...)
> and is-expressions?
VERY good question, I'm not sure.
From a purely practical perspective I'd say it should pass
__traits(compiles, ...) and is-expressions purely because the
kind of things that @ctfeonly would be used to cull from the
produced binaries are used as is-expressions (e.g. the template
lambda that determines isInputRange), although I expect it use to
be rare. Ultimately I think this this feature would fall in to
the category of "use responsibly" and it would be the
responsibility of the user. They could always reflect on the
presence of the attribute if need be.
From a point of consistency, probably however semantic
constraints on things like LDC's magic attributes are done. I'm
not sure how that is handled, but I suspect that
__traits(compiles,...) does not take it into account. Johan?
I will think more on it.
Thanks.
More information about the Digitalmars-d
mailing list