Functions cannot be interpreted while being compiled
Timon Gehr via Digitalmars-d
digitalmars-d at puremagic.com
Wed Aug 24 23:45:31 PDT 2016
On 25.08.2016 05:11, ketmar wrote:
> On Thursday, 25 August 2016 at 02:20:31 UTC, Andrei Alexandrescu wrote:
>> Just got the error above. Is this fundamental or an implementation
>> artifact? -- Andrei
>
> fundamental.
(The remainder of the post is describing implementation details; this
doesn't explain why the limitation is fundamental.)
> interpreter operates only on fully semanticed functions,
> where all the analysis, type inferencing and lowering is already
> complete (otherwise interpreter have to reimplement *all* the frontend
> again, to do exactly same work).
> ...
Usually, to do exactly the same work, one would just use exactly the
same code.
> the error mesage you got means that CTFE tried to execute something that
> is still in semantic analysis stage.
No, it means CTFE tried to execute a function of which some parts are
still in semantic analysis stage. E.g., it is clear what the following
function should mean, if it was assigned a meaning:
int foo(int x){
if(x==0) return 1;
enum r=foo(0);
return r;
}
Usually CTFE only fails if the dynamic branch actually taken runs into a
problem, so this is somewhat inconsistent.
More information about the Digitalmars-d
mailing list