Request for Comment assert(__ctfe)
Jonathan Marler
johnnymarler at gmail.com
Sun Apr 5 16:00:42 UTC 2020
On Sunday, 5 April 2020 at 13:26:22 UTC, Basile B. wrote:
> On Sunday, 5 April 2020 at 12:11:23 UTC, Stefan Koch wrote:
>> Hi Guys,
>>
>> [...]
>>
>> What do you guys think?
>>
>> Cheers,
>>
>> Stefan
>
> I'd prefer a new func attribute `@ctfe`.
> Also I find the current implementation unplesant. Cant you just
> check the assertion when they are already visited elsewhere e.g
> in dmd.expressionsem.ExpressionSemanticVisitor.visit(AssertExp)
> ? Also what if we are in a contract ?
I agree that a function attribute makes more sense for a feature
like this, however, this solution doesn't solve the general case
(i.e. elide functions that are only called at compile-time but
don't have assert(__ctfe) because they are available to be called
at runtime). Given that, I believe solving the general case is
only a matter of implementation rather than a language change.
So I would hate to add a new language feature that would become
obselete once the tooling is better.
So I say yes, I'd be fine with this "hack" to temporarily provide
a path for programs to create CTFE-ONLY functions that won't go
to code generation. It's better than the status-quo and can be
removed if we ever solve the general case.
More information about the Digitalmars-d
mailing list