On Tuesday, 14 August 2018 at 16:54:09 UTC, ixid wrote:
On Tuesday, 14 August 2018 at 13:38:16 UTC, Everlast wrote:
etc
Thanks all for the comprehensive responses. I was not clearly
separating CTFE and the compilation of the function in thinking
about it. Much clearer now.
Yeah, if you
On Tuesday, 14 August 2018 at 13:38:16 UTC, Everlast wrote:
etc
Thanks all for the comprehensive responses. I was not clearly
separating CTFE and the compilation of the function in thinking
about it. Much clearer now.
On Tuesday, 14 August 2018 at 09:12:30 UTC, ixid wrote:
This will not compile as it says n is not known at compile time:
auto fun(int n) {
static foreach(i;0..n)
mixin(i.to!string ~ ".writeln;");
return;
}
enum value = 2;
void main() {
fun(value);
}
On Tuesday, 14 August 2018 at 11:25:06 UTC, Jonathan M Davis
wrote:
On Tuesday, August 14, 2018 4:03:11 AM MDT Michael via
Digitalmars-d-learn wrote:
[...]
CTFE is triggered when a value must be known at compile-time.
So, if you have something like
[...]
That is much clearer now, thanks
On Tuesday, August 14, 2018 4:03:11 AM MDT Michael via Digitalmars-d-learn
wrote:
> The page does state that enums should trigger CTFE though.
CTFE is triggered when a value must be known at compile-time. So, if you
have something like
enum a = foo();
foo gets called at compile-time, because
On Tuesday, 14 August 2018 at 09:17:41 UTC, ixid wrote:
On Tuesday, 14 August 2018 at 09:12:30 UTC, ixid wrote:
This will not compile as it says n is not known at compile
time...
This does work if 'value' is changed to immutable and fun to
accept it. So it still seems like a missed
On Tuesday, August 14, 2018 3:12:30 AM MDT ixid via Digitalmars-d-learn
wrote:
> This will not compile as it says n is not known at compile time:
>
> auto fun(int n) {
> static foreach(i;0..n)
> mixin(i.to!string ~ ".writeln;");
> return;
> }
>
> enum value = 2;
>
>
> void main() {
>
On Tuesday, 14 August 2018 at 09:17:41 UTC, ixid wrote:
On Tuesday, 14 August 2018 at 09:12:30 UTC, ixid wrote:
This will not compile as it says n is not known at compile
time...
This does work if 'value' is changed to immutable and fun to
accept it. So it still seems like a missed
On Tuesday, 14 August 2018 at 09:12:30 UTC, ixid wrote:
This will not compile as it says n is not known at compile
time...
This does work if 'value' is changed to immutable and fun to
accept it. So it still seems like a missed opportunity as enum
shouldn't be able to change either.
This will not compile as it says n is not known at compile time:
auto fun(int n) {
static foreach(i;0..n)
mixin(i.to!string ~ ".writeln;");
return;
}
enum value = 2;
void main() {
fun(value);
}
But making it a template parameter fun(int n)() and
10 matches
Mail list logo