On Friday, 9 July 2021 at 22:53:10 UTC, Ali Çehreli wrote:
On 7/8/21 11:11 AM, DLearner wrote:
Hi
Please confirm that:
`
assert(false, __FUNCTION__ ~ "This is an error message");
`
Will _not_ trigger GC issues, as the text is entirely known at
compile time.
Best regards
One way of forcing compile-time evaluation in D is to define an
enum (which means "manifest constant" in that use). I used
@nogc to prove that there is no GC allocation as well:
@nogc
void main() {
enum msg = __FUNCTION__ ~ "This is an error message";
assert(false, msg);
}
Ali
this is very bad, assert are good because they are one liner,
making it 2 line to avoid GC is just poor design, compiler should
be smarter