CTFE & code generators based on PEG grammars?
ag0aep6g
anonymous at example.com
Sat Apr 6 14:59:18 UTC 2019
On 06.04.19 16:19, Alex wrote:
> That is CTFE is CT RTFE where runtime functions are executed at compile
> time when the inputs are CT.
You may have the right idea, but the last part of that sentence is
wrong/misleading. CTFE happens when the result is required at CT. The
inputs must be available at CT, but that alone doesn't trigger CTFE.
Examples:
----
bool f(string s) { return __ctfe; }
void main()
{
import std.stdio: readln;
enum x = f("foo"); /* CTFE */
enum y = f(readln()); /* error, because "readln" can't be CTFEd */
auto z = f("foo"); /* not CTFE */
}
----
More information about the Digitalmars-d-learn
mailing list