On Friday, 1 July 2016 at 23:11:34 UTC, Hiemlick Hiemlicker wrote:
On Friday, 1 July 2016 at 22:55:21 UTC, qznc wrote:
On Friday, 1 July 2016 at 22:23:23 UTC, Hiemlick Hiemlicker
wrote:
It seems D won't replace
encrypt("This string will still end up in the binary");
with "skadf2903jskdlfaos;e;fo;aisjdfja;soejfjjfjfjfjfjfeij"
or whatever the ctfe value of encrypt actually is.
This also seems like a bug in D because manifest constants
used as sole arguments to ctfe'able functions should be
replaced by the function result.
CTFE is explicit. You could make it `encrypt!"encrypted at
compile-time"`. Then let encrypt return some struct, which
decrypts at runtime.
? I thought CTFE was for normal functions?
I guess I was mistaken ;/
CTFE is triggered when the result is immediately required to be a
compile-time constant.
auto x = anyFunc("fdsa"); // anyFunc executed at runtime
static x = anyFunc("fdsa"); // anyFunc executed at compile time
enum x = anyFunc("fdsa"); // ditto
template value argument are also of course required to be
compile-time constants, so passing the immediate result of a
function call to a template will cause the function to be
evaluated at compile time.
The way I think about it is that functions are (attempted to be)
executed at ctfe on an as-needed basis.